开发者

Get Notified of popViewController

I need to save my data by calling a method I already have when a viewController is popped using the back button created by 开发者_Python百科the UINavigationController.

Is there a way to get a delegate callback or a notification I didn't see anything in the documentation?


In your viewWillDisappear method, you can check the property:

[self isMovingFromParentViewController]

to find out if the view is disappearing as a result of being popped off the stack or not.


You will be notified that the view will be disappearing, with the view controller method viewWillDisappear:, however, this will be called each time the view is moved offscreen, whether that means the controller is popped or a new controller is pushed, or whatever else may cause your view to disappear.

Perhaps a better design would be to save your data in your controllers dealloc method. Normally, a navigation controller is the owner of a view pushed into it's stack, so popping it usually causes it to deallocate. This isn't always the case though and depends on how you've written your app.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜