views:

1965

answers:

1

In this (http://stackoverflow.com/questions/843534/flip-view-iphone) post, I have created a flip view for my iPhone app. Now, I want to make sure that whenever the user hits the 'Back' button in the navigation bar, the next time around when he drills down to the flippable view, this view is in its original, non-flipped position. Currently, the app actually loads the correct view, but somehow, when you try to flip it over, it cannot doesn't load the flip view, and presents a black background only. One solution could be to assign the flip back method ("showLessInfo") to the navigation button, and that is what I need your help for. Alternatively, and quite likely a better idea for me would be to understand, why the flip view is not loaded the second time around. Any suggestion is welcome!

+5  A: 

You can override the viewWillAppear: method on your flip view's view controller and make sure behind the scenes it loads the proper view before showing (remember to call [super viewWillAppear:animated]).

Or else, you could override the viewWillDisappear and make sure things are cleaned up on the way out. It will get invoked when the user taps the back button.

Ramin
make sure you include the full method name "(void)viewWillAppear: (BOOL) animated" Rightly or wrongly I copied from the above post and it took me a while to realise I was missing the animated part, xcode threw out no errors either!
JonB
Thanks, I've updated the code snippet to avoid confusion. Another thing to consider is that viewWillAppear/viewWillDisappear are called on a given view in a number of situations: when you first get into the view (i.e. as part of a NavController scrolling over to the view), when someone taps the back button to slide back to the view from a next-level view, when a modal dialog appears and is dismissed over the view, or when you use a flip effect. So you may want to watch out for those other situations as well.
Ramin