工作栏中的Barbutton项目标题在IOS 6上可见,但在IOS 7上不可见

时间:2014-06-02 19:57:53

标签: ios7 uitoolbar

我正在使用以下代码来处理工具栏&它显示的是IOS 6的标题,但不是IOS 7的标题。

UIBarButtonItem *settingButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"multimedia/icon_settings.png"] style:UIBarButtonItemStylePlain                                                                  target:self                                                                 action:@selector(pressSettings:)];
UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"multimedia/icon_refresh.png"]                                                                style:UIBarButtonItemStylePlain target:self                                                                 action:@selector(pressRefresh:)];
UIBarButtonItem *helpButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"multimedia/icon_help.png"]                                                                  style:UIBarButtonItemStylePlain target:self action:@selector(pressHelp:)];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

/* Set the title of the button */
[settingButton setTitle:@"Settings"];
[refreshButton setTitle:@"Refresh"];
[helpButton setTitle:@"Help"];
[feedbackButton setTitle:@"Feedback"];

NSArray *toolbarButtons = @[settingButton, flexSpace, helpButton, flexSpace, feedbackButton, flexSpace, refreshButton];

[self setToolbarItems:toolbarButtons];

此代码适用于IOS 6但在IOS 7中仅显示条形按钮图像而不是标题。

1 个答案:

答案 0 :(得分:0)

UINavigationController为其堆栈中的每个视图控制器维护一个UIToolBar。此工具栏通常是隐藏的。因此,您需要明确显示工具栏:

[self.navController setToolbarHidden:NO];

获取viewcontroller的导航控制器并将上面的setToolbarHidden属性设置为NO。

希望它对你有所帮助。