Error when dismissing view controller

前端 未结 6 1700
时光取名叫无心
时光取名叫无心 2021-02-07 07:52

Getting an error when dismissing a view controller, not seen anything like it before, and not much about it on the internet.

heres the error: * Assertion failur

6条回答
  •  醉话见心
    2021-02-07 08:13

    You must make sure not only that present/dissmissViewController called on main thread but also you have to make sure that present/dismissViewController is called from the same parent viewController.

    For example there are two navigationController children. First child view controller presents the second child for some job that will return thru a delegate (interface). After the job is done second child dismisses itself and calls to delegate(interface) function with have to present another viweController (for example customPopup) -> that's rises the error since the second child view controller is not dismissed when the present of popup called, but already demised when the dismiss of popup called.

    So in this case:

      dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(400 * NSEC_PER_MSEC)), dispatch_get_main_queue(), { () -> Void in
                if let fs = self.scenarios[indexPath.item]{
                    fs.loadScenario()
                    sDelegate.onSelectedScenario(fs)
                }
            })
    

    will do.

提交回复
热议问题