Get notified when a view controller is about to be popped in iOS4

不想你离开。 提交于 2019-12-03 11:53:36
Jason McCreary

viewWillDisappear is the appropriate delegate. You will need to add logic within this method if you want to determine if the current view is being popped or a new view is being pushed. That's been answered here - viewWillDisappear: Determine whether view controller is being popped or is showing a sub-view controller

Dan Ray

I believe I'd go the other direction on this, and try to catch the polling from the individual viewControllers rather than the navigationController. To an individual viewController, getting popped looks like it's being deallocated, and that's totally hookable.

Subclass UIViewController, implement your notification in its -dealloc. Be sure to call [super dealloc].

Then have every view that you push into your navigation controller subclass your new custom view controller subclass. They can do whatever they do in their own viewDidUnload, and then call [super dealloc] (in this case super is your UIViewController subclass) to fire the notification.

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