这是我的代码:
@interface RootViewController : UIViewController{
}
-(IBAction)btnDetail1_Clicked:(id)sender;
@end
@implementation RootViewController
-(IBAction)btnDetail1_Clicked:(id)sender{
DetailViewController1 *mvcr = [[DetailViewController1 alloc] initWithNibName:@"DetailViewController1" bundle:nil];
[mvcr setDelegate:self];
[self.navigationController pushViewController:mvcr animated:YES];
[mvcr release];
}
@end
@protocol NotifySubclass
@optional
-(void) serviceCall_done;
@end
@interface MasterViewController : UIViewController{
id<NotifySubclass> delegate;
}
@property (retain) id delegate;
-(void) initCallService;
@end
@implementation MasterViewController
@synthesize delegate;
-(void) initCallService{
"My some other code is here."
[self performSelector:@selector(startLoading) withObject:nil afterDelay:5];
}
-(void) startLoading{
"My some other code is here."
[self performSelectorOnMainThread:@selector(loadComplete) withObject:nil waitUntilDone:YES];
}
-(void) loadComplete{
"I want to call DetailViewController1's "serviceCall_done" method from here.
[delegate serviceCall_done];
}
@end
@interface DetailViewController1 : MasterViewController <NotifySubclass>{
}
@end
@implementation DetailViewController1
- (void)viewDidLoad{
[self initCallService];
}
-(void) serviceCall_done{
}
@end
我想从的方法中调用DetailViewController1
的方法。serviceCall_done
loadCompete
MasterViewController
我曾尝试创建协议,但没有得到我在调用时必须编写协议的确切DetailViewController1
位置RootViewController
。
任何人都可以指导我吗?