I create an NavigationBar programmaticlly without using xib file. And create one left button with text "left", added to the navigationBar, and set the title to "Demo".
code :
-(void) createNavBar:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options
{
self.navBarController = [[[UINavigationController alloc] init] autorelease];
navBar = [navBarController navigationBar];
navBarController.navigationBar.bounds = CGRectMake(0, 0, 320, navBarHeight);
[navBarController.navigationBar setBackgroundImage:[[UIImage imageNamed:@"www/images/ios_hd_bg.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 2, 0)]
forBarMetrics:UIBarMetricsDefault];
[navBarController view];
navBarController.navigationItem.title = @"title";
[navBarController.view setFrame:navBarController.navigationBar.bounds];
UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
button = [self renderNavBarTextBtn:@"left" withButton:button direction:@"left"];
[navBar addSubview:button];
[[[self webView] superview] addSubview: navBarController.view];
}
however, the program can successfully set the navigationbar background image, show the left button, but cannot set the title. so strange?
complements: I use cordova framework to invoke . and The inteface just be provided to cordova invoke. Thanks for answers below, but I still can't solve my problem.
ScreenShot: (Note: showing the left button but not showing the title)