Question

I am using the below code for toolbar & it is showing title for IOS 6 but not fro 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];

This code working fine with IOS 6 but shows only bar button image in IOS 7 not title.

Was it helpful?

Solution

The UINavigationController maintains a UIToolBar for each view controller in its stack. This toolbar is normally hidden. So, you need to explicitly show the toolbar:

[self.navController setToolbarHidden:NO];

Get the navigation controller of your viewcontroller and set the above setToolbarHidden property to NO.

Hope it helps you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top