David542
David542

Reputation: 110380

What's wrong with this Objective C self.navigationController?

What additional code do I need to add to make the below work?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
    return YES;
}

It is currently throwing the error: Property 'navigationController' not found on object of type 'AppDelegate.

Upvotes: 0

Views: 1914

Answers (1)

Khanh Nguyen
Khanh Nguyen

Reputation: 11132

Method -application:didFinishLaunchingWithOptions: belongs to your AppDelegate's class, and self inside a method refers to the class that method belongs to. AppDelegate doesn't have the method navigationController that's why it complains.

You probably meant to run this code on the root view controller, not on the app delegate. Chance is that you initialized it somewhere in the same method, you just need to replace self with whatever variable that points to the root view controller:

[root view controller].navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

Upvotes: 4

Related Questions