在我的 firstviewcontroller
中,我呈现了一个 modalviewcontroller
,然后通过一个操作,我调用一个显示警报并关闭 modalview
的方法,但是当它消失时 viewWillAppear 不会被调用:
firstviewcontroller
-(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);
}
//in secondviewcontroller I use an alert view that call this method in order to dismiss modalview
- (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
不会被调用,请问我缺少什么
最佳答案
更改以下代码即可工作:
addViewController.modalPresentationStyle = UIModalPresentationFullScreen;
它会起作用。
关于ios - 关闭 modalviewwontroller 后 Viewwillappear 不会被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18063578/