【发布时间】:2011-10-21 21:42:06
【问题描述】:
我整天都在研究这个问题,但我没有找到任何关于 rootViewController 与此错误消息相关的信息。我知道问题出在哪里,但不知道如何解决。我的问题是我的 window.rootViewController 未连接或显示为空,我不知道该怎么做。我已经在代码和 IB 中尝试了所有我能想到的东西,但每当我改变某些东西时,就会发生不好的事情。这是我得到的消息:“应用程序试图在目标 UINavigationController 上推送一个 nil 视图控制器”
我可以从 NSLog 语句中看到 window.rootViewController: “window.rootViewController : (null)”
当然,在将我的 Xcode 升级到 4.2 和 ios5 之前,一切都运行良好。 :)
btw - 视图加载,但我无法使用任何按钮,它们根本不亮。而且我的导航也很好用。
这是我的 appDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[DDLog addLogger:[DDTTYLogger sharedInstance]];
NSLog(@"Viewcontroller : %@", self.viewController);
// Set the view controller as the window's root view controller and display.
//self.window.rootViewController = self.viewController;
//do it this way, previous version not supported in ios5 - may need to check version for compatibility
[self.window addSubview:self.viewController.view];
//set up navigation controller
NSLog(@"window.rootViewController : %@", self.window.rootViewController);
navigationController = [[UINavigationController alloc]
initWithRootViewController:self.window.rootViewController];
navigationController.navigationBarHidden = YES;
NSLog(@"navigationController : %@", navigationController);
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
//force this view to be landscape
[application setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated:NO];
[self.navigationController.view setTransform: CGAffineTransformMakeRotation(M_PI / 2)];
[self.navigationController.view setFrame:CGRectMake(0, 0, 748, 1024)];
[UIView commitAnimations];
return YES;
}
谢谢。
【问题讨论】:
标签: objective-c ios uinavigationcontroller ios5 xcode4.2