views:

40

answers:

2

In my application I am parsing XML to create a UITableView. When a user selects a row it changes the file that it is parsing and reloads the tableview.

I want to create a back button so that the user can go back the the previous XML page they were viewing.

In short how can I tell the navigation controller to create a back arrow for this page when all i am doing is reloading my tableview?

+1  A: 

I'd strongly suggest building another controller (i.e. UITableViewController) and push that instead of just reloading the table. This makes the button automagically, and (major plus here), it animates the whole digging down / stepping back in a way that the user is expecting it.

As a side note, I didn't manage to get a back-style button once I tried it, just a plain normal button (make a new button and set it at the navigation bar).

Eiko
+1  A: 

What you're describing is a navigation. Rather than reloading the table's data, simply push a new view controller onto the navigation stack every time a row is tapped. This is a fundamental pattern in iPhone development. Here is Apple sample code for a multi-level drill down table view.

Justin
I can't push a new tableView I have probably 20,000 XML files that are all parsed the same way. I can't create a new View controller for every XML file.
Forgoten Dynasty
Perhaps I'm misunderstanding, but couldn't you build a generic controller for displaying XML data? The view controller could push instances of itself, passing the required XML into its initializer.
Justin
But wouldn't that limit how far the user can go into the hierarchy.
Forgoten Dynasty
In that you'll eventually run out of memory, yes. Are there cycles in your navigation graph?
Justin