我在UINavigationController
内有UITabBarController
。
导航控制器中的viewDidLoad
如下所示:
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationBar.barTintColor = [UIColor blueColor];
self.navigationBar.translucent = NO;
self.navigationBar.topItem.title = @"HOME";
self.navigationItem.title = @"HOME"; // Neither works
// create three funky nav bar buttons
UIBarButtonItem *one = [[UIBarButtonItem alloc]initWithTitle:@"One" style:UIBarButtonItemStylePlain target:self action:@selector(testMethod)];
UIBarButtonItem *two = [[UIBarButtonItem alloc]initWithTitle:@"Two" style:UIBarButtonItemStylePlain target:self action:@selector(testMethod)];
UIBarButtonItem *three = [[UIBarButtonItem alloc]initWithTitle:@"Three" style:UIBarButtonItemStylePlain target:self action:@selector(testMethod)];
// create a spacer
UIBarButtonItem *space = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
space.width = 30;
NSArray *buttons = @[one, space, two, space, three];
self.navigationItem.rightBarButtonItems = buttons;
}
成功完成此操作会将导航栏更改为蓝色,但标题或按钮都不会显示。无论我尝试什么方法,我似乎无法获得它的头衔。我不知道它是否与tabviewcontroller
有关。有什么想法吗?
谢谢,