Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pushViewController not working

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

like image 773
Jos Avatar asked Jul 06 '11 12:07

Jos


People also ask

How do I push a view controller?

Pushing a view controller causes its view to be embedded in the navigation interface. If the animated parameter is true , the view is animated into position; otherwise, the view is simply displayed in its final location.

How do I get navigation controller root view controller?

The root view controller is simply the view controller that sits at the bottom of the navigation stack. You can access the navigation controller's array of view controllers through its viewControllers property. To access the root view controller, we ask for the first item of the array of view controllers.

How do I add a navigation controller to my storyboard?

Under the View menu, select Utilities→Show Object Library. In the Object Library, find the Navigation Controller object (see Figure 4-7) and drag and drop it into the storyboard, to the left side of your existing view controller (Figure 4-6).


1 Answers

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.

like image 79
Patrick Avatar answered Sep 21 '22 16:09

Patrick