kororo
kororo

Reputation: 2022

Three20 TTNavigator TTViewController automatic load XIB

I thought I want to share my knowledge with you around Three20 framework.

It is annoying if you use TTNavigator and you have custom VC that is subclass from TTViewController. It does not load the NIB automatically.

TTNavigator* navigator = [TTNavigator navigator];
TTURLMap* map = navigator.URLMap;
[map from: @"app://myvc" toViewController: [MyVC class]];

There is a workaround and pretty much elegant solution.

Just make another subclass of TTViewController and overrides the class to have this:

- (void) loadView
{
    [super loadView];

    // load automatically the NIB
    [[NSBundle mainBundle] loadNibNamed: NSStringFromClass([self class]) owner: self options: nil];
}

The VC will load the NIB automatically when the VC is being loaded for first time.

Upvotes: 4

Views: 1322

Answers (1)

The TTNibDemo project in the samples directory has a VC which is a subclass of TTViewController. This VC has a nib and it loads the nib with a function in the AppDelegate. Check it out if this does not work for you.

Upvotes: 1

Related Questions