我正在构建一个允许用户滚动浏览图片的应用程序。由于我有很多图片(从网上下载),我所做的是我有父视图上的向上和向下按钮,此外我有滚动视图。根据选定的选项(向上或向下),我将ImageClass(创建一个扩展UIViewController的类)视图添加到滚动视图。在子视图控件上设置委托方法
现在,在选定的视图上,用户可以标记点或做任何事情。
问题是如何从父视图中调用Uiviewcontroller的方法。我知道如何设置委托方法,但我想要的是父控制器可以调用任何方法,比如重画整个视图的重绘方法。
代码:现在
-(IBAction) down:(id) sender{
[scrollView2 removeFromSuperview];
}
-(IBAction) down :(id) sender {
[scrollView2 removeFromSuperview];
if(scrollView2 == nil)
scrollView2 = [[UIScrollView alloc] init];
[self.view addSubview:scrollView2];
[self.view sendSubviewToBack:scrollView2];
[scrollView2 setBackgroundColor:[UIColor blackColor]];
[scrollView2 setCanCancelContentTouches:NO];
scrollView2.clipsToBounds = YES;
// default is NO, we want to restrict drawing within our scrollview
scrollView2.indicatorStyle = UIScrollViewIndicatorStyleWhite;
// CSImageView is a class which of the type UIViewController
imageVie = [[CSImageView alloc] init];
[scrollView2 addSubview:imageVie.view];
[scrollView2 setContentSize:CGSizeMake(1500,1500)];
[scrollView2 setScrollEnabled:YES];
[imageView release];
}
,从父视图控制器我想打电话说:
imageVie.redraw();方法
代码CSImageView
@interface CSImageView : UIViewController {
NSNumber *imageId ;
}
@property (nonatomic, retain) NSNumber *venueId;
-(void) redraw;
@end
@implementation CSImageView
@synthesize imageId;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(void) redraw {
NSLog(@"I am ehre in the test function");
}
@end
能否请你帮我在相同的。我无法调用重绘方法。任何输入将不胜感激。
嘿卡梅隆, 我也试过这样做。但我无法访问该方法。任何输入同样将不胜感激。请让我知道如何继续相同。 – Pintu 2011-04-06 20:16:03