我正在使用以下代码来处理工具栏&它显示的是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中仅显示条形按钮图像而不是标题。
答案 0 :(得分:0)
UINavigationController为其堆栈中的每个视图控制器维护一个UIToolBar。此工具栏通常是隐藏的。因此,您需要明确显示工具栏:
[self.navController setToolbarHidden:NO];
获取viewcontroller的导航控制器并将上面的setToolbarHidden属性设置为NO。
希望它对你有所帮助。