I’ve got a TabBarController in my app and in it I’ve got a few NavigationControllers. I’ve got all this stuff simply made in interface builder.
Now I want to implement my custom navigationcontroller so I created a class:
#import <UIKit/UIKit.h>
@interface DetailNavigationController : UINavigationController
@end
@implementation DetailNavigationController
- (id)initWithRootViewController:(UIViewController *)rootViewController
{
self = [super initWithRootViewController:rootViewController];
if (self) {
NSLog(@"I work!");
}
return self;
}
- (void) dealloc {
[super dealloc];
}
@end
And in Interface builder I added this class as Custom Class to the navigation controller I want. Now when I start the app and select the tab with this navigation controller it works but the initWithRootController is not called. I guess it’s completely ignoring the class and runs as default navigation controller.
Do I need to specify anything more in interface builder or do I need to specify this controller programatically somewhere in tabbar delegate?
Thanks.
If you’re creating the navigation controller in interface builder, you will need to override
initWithCoder:, notinitWithRootViewController:. The xib contains an instantiated version of your object, with the root view controller already set.