我有UIToolbar(底部)的UIViewController,我想在UINavigationBar中添加一個UINavigationController。 但是不顯示UINavigationController。在UIViewController中添加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];' – HelmiB