开发者

iPhone Sdk: How to add a second UINavigationController?

开发者 https://www.devze.com 2023-01-11 19:59 出处:网络
i created an app from th开发者_高级运维e navigation-based template given by apple. Now i want to add a second navigation controller to my application including a new UITableView. Can anybody show my h

i created an app from th开发者_高级运维e navigation-based template given by apple. Now i want to add a second navigation controller to my application including a new UITableView. Can anybody show my how to do this? Thanks!


I think this can be done. In your app delegate you normally do something like [window addSubview:navController.view]. UIWindow is just a UIView. So if you create two UIView ivars in the UIViewController that will contain the two nav controllers you should be able to do a similar thing:

@interface MyViewController : UIViewController
{
  UIView* upperView;
  UIView* lowerView;
}

etc...

MyUpperRootViewController* myUpperRVC = [[MyUpperRootViewController alloc] init...
UINavigationController* myUpperNavController = [[UINavigationController alloc] initWithRootViewController:myUpperRVC];
[upperView addSubview:navController.view];
[myUpperRVC release];

and something similar on lowerView.

In the root view or subseqeunt views pushed onto the controllers access them in the usual way as if there was one nav controller. [self.navigationController push... should behave normally.

For animating in (and out) the view controllers, just apply the animation to the views - upperView or lowerView. You might want to start with their frames off the visible display and then change them to something visible inside an animation block.

0

精彩评论

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