Iphone 如何从UIWindow导航到UIView

Iphone 如何从UIWindow导航到UIView,iphone,objective-c,uinavigationcontroller,Iphone,Objective C,Uinavigationcontroller,我有一个iphone应用程序,它有一个UIWindow。我想添加更多的UIView。 我试过这个 SettingsViewController *viewctrl = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil]; [self.navigationController pushViewController:viewctrl animated:YES]; [viewctrl

我有一个iphone应用程序,它有一个UIWindow。我想添加更多的UIView。 我试过这个

SettingsViewController *viewctrl = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil];
[self.navigationController pushViewController:viewctrl animated:YES];
[viewctrl release];

但它不起作用。任何人都可以帮助我。提前感谢。

您需要显示更多代码。

如果未设置导航控制器,则self.navigationController默认为nil。

首先检查您的
self.navigationController
是否为
nil
。它是如何工作的。是否有错误,会发生什么?我已将NSLog(@“SettingsPressed”);它正在执行。但不转到下一个视图当前我的应用程序显示MainWindow.xib。。它不在UIViewController中当我的应用程序启动时,将加载我的MainWindow.xib。我想在单击UIBarButtonim时导航uiviewcontroller。所以我调用一个函数-(iAction)setingsPressed:(id)sender{}。我添加了ibuinavigationcontroller*导航控制器@属性(非原子,保留)UINavigationController*navigationController;在我的Appdelegate.h-(iAction)设置中,所述:(id)发送方{……}此函数写在上面