self.navigationController pushViewController无法正常工作 [英] self.navigationController pushViewController not working
问题描述
我有一个带有单个 UIViewController
的View应用程序。然后我通过IB添加一个 UITableViewController
,我试图通过<按下按钮显示 UITableViewController
code> UIViewController (我的主要观点)。我按下按钮(IBAction)包含以下代码,我试图通过该代码推送我的 UITableViewController
视图并显示它:
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];
我的 DataViewController
根本没有得到推动进入堆栈并显示,
我也检查过上面的代码, self.navigationController = nil
可能这是问题的根源。如果是这样,如何纠正它?
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?
请帮忙。
推荐答案
UINavigationController *navCtrlr = [[UINavigationController alloc]initWithRootViewController:yourfirstviewController];
[self.window setRootViewController:navCtrlr];
navCtrlr.delegate = self;
navCtrlr.navigationBarHidden = YES;
在 appdelegate.m
中创建导航控制器然后你可以导航到任何 uiviewcontroller
Create navigation controller in appdelegate.m
then you can navigate to any uiviewcontroller
这篇关于self.navigationController pushViewController无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!