I’ve created a very simple app with a UINavigationController as the root controller but when I run it only half (the left hand side) of the navigation bar is displayed. Why is this? It seems strange – if I’ve done something wrong you’d think it wouldn’t display at all, but instead its exactly half!
The controller looks like this:
@interface RootController : UINavigationController { UIWebView* webView; NSMutableString *htmlString; }
With corresponding @property declarations and @synthesize.
I’m not using any .nibs for the view controller/view. The app delegate is:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { RootController* theRVC = [[RootController alloc] init]; self.window.rootViewController = theRVC; [theRVC release]; [self.window makeKeyAndVisible]; return YES; }
And the controller has the following relevant code:
- (void)loadView { webView = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; self.view = webView; [webView release]; } - (void)viewDidLoad { [super viewDidLoad]; }
You shouldn’t derive from
UINavigationController.Instead, derive your
RootControllerclass from UIViewController.Then, in the application delegate you init a UINavigationController passing in the RootController, and set it as the windows rootViewController.