“Application tried to present modally an active controller”?

后端 未结 8 1344
孤城傲影
孤城傲影 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: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.

提交回复
热议问题