pushViewController not working

Jos picture Jos · Jul 6, 2011 · Viewed 30.5k times · Source

I have an application which has a view called store. In this view there is a button which loads the DetailView. Problem is that this detailview doesn't load/show. This is the code I use:

-(void)knop:(id)sender{
    categoryView = [[CategoryView alloc] init];
    //show detail view using buttonDetail...
    [self.navigationController pushViewController:categoryView animated:YES];
    [categoryView release];
    NSLog(@"Button is working");
}

The log "Button is working" logs, so the pushViewController line is also triggered.

categoryView is made in my .h file:

 CategoryView IBOutlet *categoryView;
}
@property (nonatomic, retain) IBOutlet CategoryView *categoryView;

In the store.xib there is a UIViewController with an outlet linked to the categoryView outlet.

Somewhere else in my app this is working, and I can't seem to find out why this one isn't

Any help would be appreciated! THNX

Answer

Patrick picture Patrick · Jul 6, 2011

Did you assign the UINavigationController in your AppDelegate?

@interface

@property (nonatomic, retain) IBOutlet RootViewController *rootViewController;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

@implementation didFinishLaunchingWithOptions

rootViewController = [[RootViewController alloc] initWithNibName:@"RootView" bundle:nil];
navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];

[window addSubview:navigationController.view];
[self.window makeKeyAndVisible];

pushViewController works fine then through the whole App.