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{开发者_如何学Go
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
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.
It sounds like
NSLog(@"nav controller = %@", self.navigationController);
will show that navigationController is nil.
I suggest creating a new project of navigation type and see how this should be setup.
I have found it. Since I was using a tabbar based app, I needed to change the store tab to Navigation Controller. When I changed it, it worked! Thanks for all your support!!!
If your view is nib based, you need to use:
categoryView = [[CategoryView alloc] initWithNibName:nibName bundle:nibBundle];
Hope this helps.
精彩评论