简体   繁体   English

添加导航按钮标签栏控制器

[英]add navigation button tab bar controller

I am trying to add navigation button to top bar in a UITabController but the button isn't showing. 我想在UITabController中添加导航按钮到顶部栏但是按钮没有显示。

UIBarButtonItem * leftButtonItem = [[UIBarButtonItem alloc] initWithTitle: @"SETTING" style: UIBarButtonItemStyleBordered target: self action: @selector(permanentlyCloseWelcomeView)] ;
[[self navigationItem] setLeftBarButtonItem: leftButtonItem];

Is the view controller inside a UINavigationController? 视图控制器是否在UINavigationController中? You only get self.navigationItem if it is. 你只能获得self.navigationItem。 Check it in the debugger, I bet it's nil on your second line. 在调试器中检查它,我打赌你的第二行是零。

You need to embed the view controller in a navigation controller, or if you just want the bar and not a nav controller, you put the bar button item on your manually-created nav bar. 您需要将视图控制器嵌入导航控制器中,或者如果您只想要条形而不是导航控制器,则将条形按钮项目放在手动创建的导航栏上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM