Reputation: 79
I am trying to learn the nuts and bolts of using UIToolbar in iOS 7. To accomplish that, I used the following pre-iOS 7 code: http://www.edumobile.org/iphone/iphone-apps/using-toolbars-in-iphone/
The code works fine in iOS 6 but it seems that neither the toolbar nor its items are visible in iOS 7. Would you be so kind as to help me find a solution to the problem or point out resources that I could use to implement toolbars in iOS 7.
Thank you!
Upvotes: 1
Views: 2661
Reputation: 11016
You need to explicitly show the toolbar:
[self.navController setToolbarHidden:NO];
Btw, setting the root view controller of the app should be done with UIWindow
's setRootViewController:
, instead of just adding the view as a subview of the window.
So your code may look like:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.rootViewController = [[MainViewController alloc] initWithNibName:nil bundle:nil];
self.rootViewController.title = @"Main View";
self.navController = [[UINavigationController alloc] initWithRootViewController:self.rootViewController];
self.navController setToolbarHidden:NO];
[self.window setRootViewController:self.navController];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
This is purely a subjective opinion, but edumobile.org doesn't seems to be the best website out there to learn iOS/ObjC. These courses seems outdated / with bad practices and WOT gave me a warning when entering... Nothing against them though, I didn't know this website before answering.
Upvotes: 6