参考链接
问题原因分析:Tabbar一个viewController只是被Init,但从未显示过,所以viewDidLoad并未被执行。但dealloc事件中却调用了removeObserver方法,导致错误。
不过这只是其中一个原因,不覆盖所有情况。
Apple Docs say there is a way to add observer when view is visible only. According to Figure 1 - Valid State Transitions you can use pair
问题原因分析:Tabbar一个viewController只是被Init,但从未显示过,所以viewDidLoad并未被执行。但dealloc事件中却调用了removeObserver方法,导致错误。
不过这只是其中一个原因,不覆盖所有情况。
Apple Docs say there is a way to add observer when view is visible only. According to Figure 1 - Valid State Transitions you can use pair
viewWillAppear/viewWillDisppear for adding and removing observers. At the same time you can use init/dealloc pair, but not viewDidLoad/dealloc - view can be not loaded, but controller deallocated.
评论
发表评论