Inherit from UINavigationController

Posted by d.andreykiv on Stack Overflow See other posts from Stack Overflow or by d.andreykiv
Published on 2010-03-12T08:12:01Z Indexed on 2010/03/12 8:17 UTC
Read the original article Hit count: 322

Filed under:
|

Hi. I'm developing iphone app with UITabBarController as main view. Every ViewController in each tab is UINavigationController which must have a same button in leftBarButtonItem. Can I inherit some class from UINavigationController and override it's -(id) initWithRootViewController:(UIViewController *)rootViewController method to realize this ?

I made something like this. But this code doesn't work;

@implementation MainNavagaionController 

-(id) initWithRootViewController:(UIViewController *)rootViewController {

if (self = [super initWithRootViewController:rootViewController]) {

// Set user name title UIBarButtonItem * userNameButton = [[UIBarButtonItem alloc]initWithTitle:@"Title" style:UIBarButtonItemStylePlain target:self action:nil];
self.navigationItem.leftBarButtonItem = userNameButton; [userNameButton release];

}

return self; }

@end

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c