views:

1339

answers:

3

Application shows information about planets, their moons, and etc. It shows a list of planets, let user select a planet and see its details and then bookmark/unbookmark it. I have a view which shows user the details of selected planet, it also contains a add/remove bookmark button. If user clicks that button, that bookmark is added/removed and another view is pushed on top of current view to tell user that bookmark has been deleted.

Now question is when user clicks the back/planet details button on the left of navigation bar shown on the status view and he gets back to the planet details view, he is still shown the add/remove (whichever was shown previously) button whereas it should now be remove/add (according to the previously loaded button) according to the code i wrote.

What i can understand is that when user clicks that back button, the previous view isn't reloaded, the status view just gets popped up. Is there a way i could make app run setNeedsDisplay or something that could reload the bookmark details viewDidLoad code when user click the back button on status view?

Or is there another solution possible?

Its very confusing to the user as he thinks that he just removed/added the bookmark but the button is still asking him to add/remove...

That status view is also used by other section of the code to show results to the user of an action so i can't change its code, or may be i can check the previous view in it, check if it was planet details and then reload its contents...

A: 

Take the code that sets the button up in the viewDidLoad method and move it into viewWillAppear. It should update the button properly when you re-enter the view.

crackity_jones
ooopsss, see the text below :P :d. didn't reload the page...Thanks
Shoaibi
A: 

I found a solution: Such code (button changing after a popViewController or such events) should be written in viewWillApear to make it run everytime the view is loaded no matter what.

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

Shoaibi
A: 

set the delegate correct and

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