开发者

"Infinite Drill-down" with UINavigationController

开发者 https://www.devze.com 2022-12-30 01:37 出处:网络
Can anyone suggest an article or perhaps an example of how to create an \"infinite drill-down\" with UINavigationController like you see 开发者_开发问答in the Facebook, IMDB and BrightKite apps?The UI

Can anyone suggest an article or perhaps an example of how to create an "infinite drill-down" with UINavigationController like you see 开发者_开发问答in the Facebook, IMDB and BrightKite apps?


The UINavigationController is designed to be used this way. If memory becomes an issue, the nav controller will release hidden views and reload them when the time comes to navigate back down the stack. Apple recommends you load your UIViews from a NIB for this reason.

http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/NavigationControllers/NavigationControllers.html#//apple_ref/doc/uid/TP40007457-CH103-SW28

Scroll down to item #4, "Configure the view for your root view controller."


Never having done this... I would approach this by keeping a stack with a light-weight object containing the contents of the previous view (perhaps just a URL?). Rather than just push on a new UIViewController to the UINavigationController, you would pop your current one, without animation, then push on the new view. However, I don't think this would properly handle the nice animation.

Another way that comes to mind would be to manipulation the viewControllers array of UINavigationController. After pushing on a new view, just remove the previous view from the array. That way the UINavigationController stack would only ever be 1 or two elements deep. Handling the back button would create the proper view, insert it into the viewControllers array, then pop off the current one. Your state would be managed by the lightweight object stack, not heavyweight view controllers.

-dan

0

精彩评论

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

关注公众号