开发者

What's the correct way to represent a linear process in CocoaTouch (UIKit)?

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.

开发者_如何学Go

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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜