UInavigationbar项目

时间:2014-06-25 06:17:02

标签: ios

我在uinavigationcontroller(aap的rootviewcontroller)上添加了subview作为uiviewcontroller,并且此视图控制器是subview作为rootviewcontroller自我。窗口。 在Appdelegate中我使用:

self.window.rootViewController = self.rootVC;

并在viewdidload RootViewController我写道:

    [self.navVC.navigationController.navigationBar setBarStyle:UIBarStyleBlack];
    [self.navVC.navigationController.navigationBar setTranslucent:YES];
    self.navVC.navigationController.navigationBarHidden = NO;
    [app.rootVC.view addSubview:self.navVC.view];
    self.navVC.delegate = self;

此处显示navigationbar,但我无法在导航栏上显示uibarbutton个项目。示例代码:

 leftBtn = [[UIBarButtonItem alloc] initWithTitle:@"Left" style:UIBar
 flxBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBa
 rightBtn1 = [[UIBarButtonItem alloc] initWithTitle:@"Right" style:UIBar
 rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"Right" style:UIBar


 [self.navVC.navigationItem setLeftBarButtonItem:leftBtn];
 [self.navVC.navigationItem setRightBarButtonItems:@[rightbtn1,rightbtn,flxBtn]];

有人可以帮助我解决我的问题。如何更改navigationbar的外观以及如何显示uibarbutton项?

1 个答案:

答案 0 :(得分:0)

您只需要更改

即可
[self.navVC.navigationItem setRightBarButtonItems:@[rightbtn1,rightbtn,flxBtn]];

[self.navigationItem setRightBarButtonItems:@[rightbtn1,rightbtn,flxBtn]];

[self.navVC.navigationItem setLeftBarButtonItem:leftBtn];

[self.navigationItem setLeftBarButtonItem:leftBtn];`