destroy a view when back button is pressed

My navigation controller is organized this way:

FirstViewController -> SecondViewController -> ThirdViewController

in the First I do a search on the web and I display the result in a UITableView when I select a cell I push to the Second where I do another search based on key previously pressed and I display some information and a button for "more info" when I press the button I push to the Third view and this works fine...

The problem is when I press two times the back button for doing another search: when I arrive at the third view I display every time the informations about the first search!

this is because I do the display of information in loadView and this is called only the first time, right?

How should I do?

thank you!

Answers


Indeed viewDidShow is called after the view has been loaded and created from the NIB file. This means you should only use that method to do initialization stuff.

Add a new method and call it everytime you have new results:

- (void) updateAndShowResults
{
    // Code to update third view goes here
    // and is always called whenever some new results are available
}

You'd call it from the first or second view controller like this:

[thirdView updateAndShowResults];

Hope that helps. Please mark the best answer by clicking the "√" on the left! Thanks.


Need Your Help

Does HABTM jointable needs index?

ruby-on-rails database ruby-on-rails-3 indexing migration

Is it necessary to add_index on HABTM join table? I use t.belongs_to (aka t.references). Here is code

Using Rails form helpers with Mongoid

ruby-on-rails ruby-on-rails-3 mongoid

I'm trying to build a new Rails app with MongoDB using Mongoid as the ORM. The authentication is handled by the sorcery gem.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.