Question

i have implemented a tabbarcontroller with 5 tabs each connected to a view.

the tabBarcontroller is created and default view allocation happens in another view.

everythine looks fine but i have a bug.

each view in the tab have buttons that trigger other views. these views don't have tabs so to get back to a tab view i use a back button.

when i press the back button i don't want the view ( with the tab ) to be created from scratch. so i have put the relevant code in viewdidload rather than viewwillappear. ( this choice is because this view downloads data from server and it becomes time consuming to put the code at this point in viewwillappear )

However if i am returning from current tab to a tab that i had previously touched and viewed. I want view to be loaded from scratch because data should be downloaded again at this point. but since i am using viewdidload rather than viewwillappear the old view is not refreshed.

how can i achieve this conditional refreshing of view depending upon whether i am coming from another tab or a from a view with back button

Was it helpful?

Solution

One way to do this is the isMovingToParentViewController method in your view controller. This will enable you to detect if your current stack has been popped from navigation controller.

There's an answer here that explains how to use it, and links to Apple's documentation.

As you can see from that thread, you can also use NSNotificationCenter to do this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top