【发布时间】:2013-08-05 20:45:16
【问题描述】:
关闭modalviewcontroller后如何拨打viewwillappear?
任何想法请因为在解雇我的viewwillappear 后没有被调用:
以模态方式展示我的视图控制器: //第一视图控制器:
-(IBAction)AddActivity:(id)sender{
CreateActivity *addViewController = [[CreateActivity alloc] initWithNibName:@"CreateActivity" bundle:nil];
addViewController.delegate = self;
addViewController.modalPresentationStyle = UIModalPresentationFormSheet;
addViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:addViewController animated:YES];
addViewController.view.superview.frame = CGRectMake(50, 260, 680, 624);
}
//secondvioewcontroller : 我创建了一个 alertview 来关闭这个 modalview ,但是 viewwillapear 没有被调用:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0){
if ([self respondsToSelector:@selector(presentingViewController)]){
[self.presentingViewController dismissModalViewControllerAnimated:YES];
}
else {
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
}
}
【问题讨论】:
-
你确定吗?你怎么检查?根据我的经验,viewWillAppear 总是在呈现的模式被关闭时为呈现的视图控制器触发。
-
我正在编辑我的帖子,看看我做了什么,我错过了什么?
-
@OuassimMouyarden 您需要先学习如何正确地考虑 OOP,然后再开始做事。话虽如此,我仍然会帮助你,暂时。当 UIAlertView 上的按钮被按下时,您希望发生什么?
-
我想关闭我的 modalview ,并调用我的 firstviewcontroller 的 viewwillappear 来做一些操作
-
代码对我有用,并且调用了 viewDidAppear。模态视图控制器被解散了吗?
标签: iphone ios objective-c