【发布时间】:2013-07-20 15:56:18
【问题描述】:
我有一个带有 UIToolbar 的 UIViewController(在底部),我想在里面添加一个带有 UINavigationBar 的 UINavigationController。 但是 UINavigationController 没有显示出来。
MyViewController.m:
- (void)viewDidLoad
{
[super viewDidLoad];
int toolBarHeight = 44;
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, [self.view bounds].size.height-toolBarHeight, [self.view bounds].size.width, toolBarHeight)];
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:nil action:nil];
toolBar.items = @[button];
[self.view addSubview:toolBar];
MyNavigationController *myNav = [[MyNavigationController alloc] init];
[self addChildViewController:myNav];
}
【问题讨论】:
-
需要在navigationController里面添加viewController。
[[MyNavigationController alloc] initWithRootViewController:viewController];
标签: iphone ios uiviewcontroller uinavigationcontroller