Bugs encountered in the Modal switching scene of ios development

Project scene:

Code segue: Use the code UIModalTransitionStylePartialCurl (vertical screen flip effect transition) to switch to the new ViewController, use the code dismissViewControllerAnimated:YES to return to the previous ViewController when the animation is stuck

Problem Description:

1. Use the code UIModalTransitionStylePartialCurl (vertical screen flip effect transition) to switch to the new ViewController

//代码实现切换到第四场景
- (IBAction)gotoFourthView:(id)sender {
    
    
    //获取Main.storyboard
    UIStoryboard * sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    //获取新的viewcontroler
    FourthViewController * fvc = [sb instantiateViewControllerWithIdentifier:@"fourthview"];
    //过度翻页效果
    fvc.modalTransitionStyle = UIModalTransitionStylePartialCurl;
    //过度页面采用modal样式
    fvc.modalPresentationStyle = UIModalPresentationFullScreen;
    //展示新页面
    [self presentViewController:fvc animated:YES completion:nil];
}

2. When the new ViewController uses the code dismissViewControllerAnimated:YES to return to the previous ViewController, the animation will be stuck.

//返回上一层页面
- (IBAction)backToPreviosView:(id)sender {
    
    
    UIViewController *presentingVc = self.presentingViewController;
    //    while (presentingVc.presentingViewController) {
    
    
    //        presentingVc = presentingVc.presentingViewController;
    //    }
    if(presentingVc){
    
    
        [presentingVc dismissViewControllerAnimated:YES completion:nil];
    }
}

3. As shown in the figure:

Insert picture description here


Cause Analysis:

Tip: fill in the analysis of the problem here:
unknown reason


solution:

  1. Do not use UIModalTransitionStylePartialCurl style, use the other three to return to normal, for example:
  • UIModalTransitionStyleCoverVertical
  • UIModalTransitionStyleFlipHorizontal
  • UIModalTransitionStyleCrossDissolve
  1. If you must use the IModalTransitionStylePartialCurl style, select NO
    [presentingVc dismissViewControllerAnimated: NO completion:nil];

Guess you like

Origin blog.csdn.net/Suarez1987/article/details/108385565