0

i'm pretty new in the iPhone/iPad developing. In my application i have a uitabcontroller and in one tab, i'll add a uinavigation controller. But I realized that i need the same design and function in other tab, I would like the reuse the code and the only change would be the xml file that the section is using.

Is there anyway to add a parameter in a uinavigation controller for the main view? Thanks in advance.

Chris Hanson
  • 54,380
  • 8
  • 73
  • 102
threeleaf
  • 23
  • 6

1 Answers1

0

You could subclass UINavigationController, add in the common code, and have all your tab's view controllers use this subclass. So, for example, you could do:

@implementation MyNavController : UINavigationController {
    NSString *foo;
}

- (id)initWithFoo:(NSString *)aFoo;

@end

And implement initWithFoo like:

- (id)initWithFoo:(NSString *)aFoo {
    if (self = [super init]) { // or whatever init method you want to use for UINavigationController
        foo = [aFoo retain];
    }
    return self;
}

Hope this helps!

donkim
  • 13,119
  • 3
  • 42
  • 47
  • Ok, I think i got it. Instead of adding the navigation controller using the Interface Builder, I will add it manually by code. Will try this! – threeleaf Jan 02 '11 at 20:54
  • Well, you could use Interface Builder. Granted, I personally don't use it myself, but you could tie an IB object to a class that subclasses a common parent class. – donkim Jan 02 '11 at 21:33