I have a View application with a Single UIViewController
. I then add a UITableViewController
through the IB, and I am trying to display the UITableViewController
through a button press in the UIViewController
(my main view). My button press (IBAction) contains the following code through which I am trying to push my UITableViewController
view and display it:
DataViewController *dataController = [[DataViewController alloc] initWithNibName: @"DataViewController" bundle:nil];
[self.navigationController pushViewController:dataController animated:YES];
[dataController release];
My DataViewController
is not at all getting pushed into the stack and displayed,
Also I have checked that in the code above, self.navigationController=nil
Probably this is the source of the problem. If so, how to rectify it?
Please help.
UINavigationController *navCtrlr = [[UINavigationController alloc]initWithRootViewController:yourfirstviewController];
[self.window setRootViewController:navCtrlr];
navCtrlr.delegate = self;
navCtrlr.navigationBarHidden = YES;
Create navigation controller in appdelegate.m
then you can navigate to any uiviewcontroller
You need to actually create a UINavigationController
. The navigationController
property tells you whether your DataViewController is currently in a UINavigationController
's hierarchy; if not (as in this case), the navigationController
property returns nil
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With