在解雇modalviewwontroller后没有调用Viewwillappear

Oua*_*den 1 objective-c uiviewcontroller ios

在我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];
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当它消失,viewWillAppear不被称为,我想要的是什么

Dhe*_*j D 5

更改下面的代码它将起作用:

 addViewController.modalPresentationStyle = UIModalPresentationFullScreen;
Run Code Online (Sandbox Code Playgroud)

它会工作.

  • 这不是一个解决方案.1)如果我需要另一种演示风格怎么办?2)当呈现视图控制器出现时,背景视图变黑并且不好 (4认同)