开发者

Maintain Title Bar in ModalViewController

When using the modalViewController, I found that that only way to keep a title bar and开发者_运维百科 buttons on the screen that I jump to was to create a navigation controller and set the modalView screen as the rootView of the navigation controller (as below).

userNameViewController = [[UserNameViewController alloc] init];

UINavigationController *cntrol = [[UINavigationController alloc]          initWithRootViewController:userNameViewController];

[self.navigationController presentModalViewController:cntrol animated:YES];

[userNameViewController release];
[cntrol release];

Why can't I simply this by using the original viewController as the modalView (as below)?

userNameViewController = [[UserNameViewController alloc] init]; [self presentModalViewController:userNameViewController animated:YES];


Because the navigation bar you usually see belongs to the navigation controller, not to its children view controllers.

You could create your own navigation bar and add it to your controller's view. However, it would require some relayout (and that's probably why it's easier to just recreate a navigation controller).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜