Search code examples
cocoa-touchuiviewcontrolleruitabbarcontrollerviewwillappear

viewWillAppear in viewcontrollers of a tabbar


In my tab-bar I have four viewcontrollers, and what happens in one can affect the view of the other, so I may need to reload some elements in the viewcontroller when it becomes visible. Normally I'd fix that by implementing viewWillAppear, but when I switch between the tabs, viewWillAppear does not seem to get called. How can I fix that, or what should I do instead?

Update: as a PS I should add that this is a tabbarcontroller in a navigationcontroller hierarchy

Cheers

Nik


Solution

  • viewWillAppear should only be used when the view appears, and not for updating it.

    Use setNeedsDisplay on the viewController's view instead.