views:

63

answers:

2

I need to represent a linear process (think wizard) in an iPad app.

In principle I could use a UINavigationController and just keep pushing new controllers for each step of the process. But this seems rather inefficient since the process I'm modeling has no notion of navigating backwards so all previous views would pointlessly stay around and use up resources.

At the moment I keep adding and removing a subview to one "master" viewcontroller and basically swapping out the contents. This works but feels rather clunky and I hope there is some nicer way to achieve this.

Additionally there needs to be an animated transition between the views. (I have this working at the moment via beginAnimations / commitAnimations)

UPDATE: To clarify my question: I'm aware that wizards usually have a back button. That's not what I'm building here.
The process that has to be shown possibly has a lot of steps (up to around 30-40 in some cases probably) so I really don't want to have 39 obsolete view controllers taking up ram.

A: 

Could you set the backBarButtonItem of each view controller's navigationItem to nil so that you don't show a back button?

Dave DeLong
That might work to hide a NavigationController's bar but as I wrote above the concept of stacking views on top of each other doesn't really fit my needs as I never need to go back to a previous view.
UloPe
@UloPe right. My suggestion is to remove the back button altogether. That way you *couldn't* go back to a different view.
Dave DeLong
@Dave DeLong I understand that, but I would still have the stack of old view controllers that I won't show again "hanging around" in the background.
UloPe
What about modifying the navigation controller's stack after pushing a new vc? You can manipulate the `viewControllers` property to only have the top-most item.
Dave DeLong
A: 

You can extend uinavigationcontrollerdelegate and check every push event the current stack size. Then you can replace with a new reduced array that contains only the desired view controllers. By the way, if you implement a good memory management and release every resource on viewDidDisappear, i'm quite sure that it's not a matter for the os to manage a huge number of "empty" view controllers. Hope it helps

marcio
Interesting idea. I will try that.
UloPe