Reloads view when clicking back button from uinavigationbar

The application displays information about the planets, their moons, etc. It displays a list of planets, allows the user to select a planet and see its details, then bookmark / unqualify it. I have a view that shows the user information about the selected planet, it also contains an add / remove bookmark button. If the user clicks on this button, this bookmark is added / removed and another view is displayed over the current view to inform the user that this bookmark has been removed.

Now the question is when the user clicks the Back / Planet button to the left of the navigation bar displayed as a status and he goes back to the plan view of the planet, it still shows the add / remove (depending on what was shown earlier), whereas now it should be removed / added (as per the previously loaded button) as per the code I wrote.

What I can understand is that when the user clicks the back button, the previous view does not reload, only the status view appears. Is there a way I could get the application to run setNeedsDisplay or something that could reload the viewDidLoad detail code when the user clicks the back button in the status view?

Or is another solution possible?

This is very confusing for the user as he thinks he just removed / added a bookmark, but the button still asks him to add / remove ...

This kind of state is also used by another section of code to display the results to the user of the action, so I cannot change its code, or I can check the previous view in it, check if it was a planet and then reload its contents ...

+1


a source to share


3 answers


Take the code that sets up the button in the viewDidLoad method and translates it into viewWillAppear. It should update the button correctly when re-entering the view.



+5


a source


I found a solution: Code like this (button change after popViewController or events like that) should be written to viewWillApear so that it runs every time the view is loaded no matter what.



Thanks to Quentarez and crackity_jones on #iphonedev at irc.freenode.net.

0


a source


set the delegate correctly and

- (void)navigationController:(UINavigationController *)navigationController
                 willShowViewController:(UIViewController *)viewController
                 animated:(BOOL)animated
{
    NSLog(@"navigationController willShowViewController");
}

      

0


a source







All Articles