Present View Controller not working with ios 9

两盒软妹~` 提交于 2019-12-04 10:23:22

Make sure the presentedViewController is nil. If presentedViewController is not nil change the code to following.

RegistrationViewController * viewController =[[UIStoryboard storyboardWithName:@"Registration" bundle:nil] instantiateViewControllerWithIdentifier:@"RegistrationViewController"];

if ([self presentedViewController]) {
    [[self presentedViewController] dismissViewControllerAnimated:NO completion:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            [self presentViewController:viewController animated:YES completion:nil];
        });
    }];
} else {
    [self presentViewController:viewController animated:YES completion:nil];

}

Sometimes a bug occurs with main loop, try to present that way

RegistrationViewController *viewController = [[UIStoryboard storyboardWithName:@"Registration" bundle:nil] instantiateViewControllerWithIdentifier:@"RegistrationViewController"];

dispatch_async(dispatch_get_main_queue(), ^{
   [self presentViewController:viewController animated:YES completion:nil];
});

try viewDidAppear in

  -(void)viewDidAppear:(BOOL)animated{ 
         [self presentViewController:viewController animated:YES completion:nil];
    }

Try the below code:

RegistrationViewController * viewController = [[self.storyboard instantiateViewControllerWithIdentifier:@"RegistrationViewController"];

[self presentViewController:viewController animated:YES completion:nil];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!