Spring
Spring

Reputation: 11835

iPhone: How to make UINavigationcontrollers inside eachother?

I have a navigation controller which I push a new tableviewcontroller for each received question to be asked to the user, so in stack it builds up to 30 controllers if there has been 30 question is asked.

The difficulty is that in some of the tableviewcontrollers I want to get the input from user by using another navigation controller inside that tableview: for example in the tableview(which is one the many views in the stack) there may be uitablecell with an arrow on the right saying choose the books you want to order, and when he clicks arrow a new tableview will slide in which includes the books to be choosen multiply with a checkmark, and then he will choose and back to main tableview and continue the main navigation there.

How can implement a new navcontroller inside the main navigation controller? or any better ideas?

EDIT: That can be an idea to push the detail view to the same controller, but then they will get popped immdidatly when user "backs" but I want to show the books (which are chosen in detail view) the main table, and when user clicks again to that cell, detailview will come with previous selected books. is this a good approach

Upvotes: 0

Views: 122

Answers (2)

Mr. Berna
Mr. Berna

Reputation: 10645

Putting an UINavigationController inside a UINavigationController is a bad idea. What you seem to really want is persistence of state data after popping some of the view controllers off your navigation controller's stack.

I would put that state information into a persistent object. If it's a tiny amount of state data I may add that data to an existing object that I know is persistent, such as the app delegate or the root view controller. I would save a more complicated set of persistent data to a custom object. This object would be retained by the root view controller, and a reference would be given to each successive view controller. This object would have the data that may have been collected by a controller that was popped off the navigation stack and therefore no longer exists.

Upvotes: 1

SideSwipe
SideSwipe

Reputation: 559

I don't really get why you dont just push the detailview of the uitableviewcontrollers to the main UINavigationController.. Could you explain that a little bit more detailed? I have no rights to comment your question, so I am afraid I have to post this as an answer.

MfG,

SideSwipe

Upvotes: 1

Related Questions