viewWillAppear is called both when going to the view and when coming back to the view from other views.
I want to select(highlight) and fade-out a cell only when coming back from other views.
Is there a delegate method to do this?
I’m using UINavigationViewController.
If you are targeting iOS 5, you can use
[self isBeingPresented]and[self isBeingDismissed]to determine if the view controller is being added or removed from the nav controller.I’m also suspecting that you could improve the logic of when you select/deselect the cell in your table view such that it doesn’t matter whether the view controller is coming or going.
The usual way to do it is this: when someone selects a row in the table view in view controller A, it gets selected/highlighted and you push a new view controller B. When view controller B is dismissed, you animate the deselection of the table view row in
viewDidAppear(so the user can see it fading out) in view controller A. You wouldn’t worry about whether view controller A has just appeared or is re-appearing, because there would only be a selected table view cell in the appropriate case.