ios - 关闭 modalviewwontroller 后 Viewwillappear 不会被调用

标签 ios objective-c uiviewcontroller

在我的 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/

相关文章:

iphone - [UIViewController disablesAutomaticKeyboardDismissal] 什么时候被调用?

ios -[NSArray componentsJoinedByString] 有条件

ios - 在 iPhone 应用程序中检测通话状态?

ios - 如何在 TouchesBegan Swift 中添加第二个接触点

iphone - iOS - 如何初始化 UINavigationController 以显示推送的 ViewController?

iphone - 对 loadView 中的 View 初始化感到沮丧

ios - 您如何在 Storyboard 中获取 UISearchbar 的结果并在另一个视点中使用这些结果?

ios - Objective-C > TableView 和 ViewController 之间的 Segue

ios - UITableViewCell 上的 UITextView

ios - 使用 ffmpeg/mobile-ffmpeg 捕捉视频