“Application tried to present modally an active controller”?

后端 未结 8 1337
孤城傲影
孤城傲影 2020-11-29 02:20

I just came across a crash showing a NSInvalidArgumentException with this message on an app which wasn\'t doing this before.

Application

相关标签:
8条回答
  • 2020-11-29 03:19

    Just remove

    [tabBarController presentModalViewController:viewController animated:YES];
    

    and keep

    [self dismissModalViewControllerAnimated:YES];
    
    0 讨论(0)
  • 2020-11-29 03:23

    In my case i was trying to present the viewController (i have the reference of the viewController in the TabBarViewController) from different view controllers and it was crashing with the above message. In that case to avoid presenting you can use

    viewController.isBeingPresented

    !viewController.isBeingPresented {
              // Present your ViewController only if its not present to the user currently.
    }
    

    Might help someone.

    0 讨论(0)
提交回复
热议问题