Tôi có một UIViewController với một UIToolbar (ở phía dưới) và tôi muốn thêm một UINavigationController với UINavigationBar bên trong. Nhưng UINavigationController không được hiển thị.Thêm UINavigationController bên trong UIViewController
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];
}
Bạn cần thêm viewController bên trong navigationController. '[[MyNavigationController alloc] initWithRootViewController: viewController];' – HelmiB