<分区>
<分区>
Possible Duplicate:
XCode 4.5.1, Application windows are expected to have a root view controller at the end of application launch
我完全是 IOS 应用程序开发的菜鸟。
我使用没有 Storyboard的 Xcode 4.5.1。
我正在升级 IOS 4 应用程序,因为它无法在 IOS 6 设备上正确运行。 包含一个问题和五个答案的主视图运行一次并在用户通过按下带有所需答案的按钮提交后停止,然后它应该重新加载一个新问题和一组新问题。
我在日志输出中得到臭名昭著的“应用程序窗口应在应用程序启动结束时有一个 Root View Controller ”。
我已阅读并尝试了 7520971 中的所有评论和解决方案但无济于事......仍然出现错误,它似乎阻止我正确加载 View 。
这是我的 appDelegate.h 中的内容
/*
* AnimViewAppDelegate.h
* AnimView
*
* Created by Administrateur local on 11-01-19.
* Copyright 2011 __MyCompanyName__. All rights reserved.
*
*/
#import <UIKit/UIKit.h>
#import "RootNavigationController.h"
@interface PPScaleAppDelegate : NSObject <UIScrollViewDelegate> {
UIWindow *window;
RootNavigationController *RootNavigationViewController;
}
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) RootNavigationController *RootNavigationViewController;
@end
我的 appDelegate.m
//
// AnimViewAppDelegate.m
// AnimView
//
// Created by Administrateur local on 11-01-19.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "PPScaleAppDelegate.h"
#import "QuestionView.h"
@implementation PPScaleAppDelegate
@synthesize window;
@synthesize RootNavigationViewController;
//- (void)applicationDidFinishLaunching:(UIApplication *)application {
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Create the main screen
//CGRect frame = [[UIScreen mainScreen] bounds];
//self.window = [[UIWindow alloc] initWithFrame:frame];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; //2012
//Create the main view controller
RootNavigationViewController = [[RootNavigationController alloc] initWithNibName:NULL bundle:NULL];
//[window addSubview:RootNavigationViewController.view];
[self.window setRootViewController:RootNavigationViewController];
//Show the main window
[self.window makeKeyAndVisible];
return YES;
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end
.h
//
// RootNavigationController.h
// IPhonePPS
//
// Created by Administrateur local on 11-02-11.
// Copyright 2011 Le Groupe CDGI Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "QuestionView.h"
#import "ResultView.h"
#import "ResultTableView.h"
@interface RootNavigationController : UINavigationController {
QuestionView *QuestionViewController;
ResultView *ResultViewController;
ResultTableView *ResultTableViewController;
}
@property(nonatomic, assign) QuestionView *QuestionViewController;
@property(nonatomic, assign) ResultView *ResultViewController;
@property(nonatomic, assign) ResultTableView *ResultTableViewController;
-(void)switchToResultMode:(QuestionPath *)QuestionPath;
-(void)switchToResultTableMode;
-(void)switchBack:(BOOL)Reset;
@end
.m
//
// RootNavigationController.m
// IPhonePPS
//
// Created by Administrateur local on 11-02-11.
// Copyright 2011 Le Groupe CDGI Inc. All rights reserved.
//
#import "RootNavigationController.h"
@implementation RootNavigationController
@synthesize QuestionViewController, ResultViewController, ResultTableViewController;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Initialization code.
QuestionViewController = [[QuestionView alloc] initWithNibName:NULL bundle:NULL];
ResultViewController = [[ResultView alloc] initWithNibName:NULL bundle:NULL];
ResultTableViewController = [[ResultTableView alloc] initWithNibName:NULL bundle:NULL];
//Set the navigation bar hidden
[self setNavigationBarHidden:YES];
//Push the question view on the stack
[self pushViewController:self.QuestionViewController animated:YES];
}
return self;
}
- (void)dealloc {
[super dealloc];
}
-(void)switchToResultMode:(QuestionPath *)QuestionPath {
[self pushViewController:ResultViewController animated:YES];
[ResultViewController setQuestionPath:QuestionPath];
}
-(void)switchToResultTableMode {
[self pushViewController:ResultTableViewController animated:YES];
}
-(void)switchBack:(BOOL)Reset{
if(Reset){
if([self.viewControllers count] == 3){
[self popToRootViewControllerAnimated:YES];
}else {
[self popViewControllerAnimated:YES];
}
[QuestionViewController resetAnswers];
}else {
[self popViewControllerAnimated:YES];
}
}
//-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
// if([self visibleViewController] == self.ResultTableViewController || toInterfaceOrientation == UIInterfaceOrientationPortrait){
// return YES;
// }else {
// return NO;
// }
//}
- (BOOL) shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
@end
花了整整两天的时间来调试这个,但我放弃了,非常感谢你对这个问题的帮助
公关
最佳答案
如果你的导航 Controller 没有 nib,最好只使用 [[alloc] init]。此外,您的导航 Controller 应使用其自己的 rootViewcontroller 进行初始化。我不知道您想成为第一个,但它应该看起来像这样:
MyFirstViewControllerClass *rootVC = [MyFirstViewControllerClass alloc] initWithNibName:@"MyFirstViewController" bundle:nil];
RootNavigationController *nav = [[RootNavigationController alloc]initWithRootViewController:rootVC];
self.window.rootViewController = nav;
关于ios - 将应用程序升级到 iOS 6 时的 Root View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13274142/
相关文章:
iphone - 获取 UIWebView 中加载的文件的 mimetypes
ios - 是否可以使用 NavigationBarViewController 作为 UINavigationController 将 View Controller 推送到堆栈上
shell - xcodebuild (Xcode 4) 的 CODE_SIGN_IDENTITY 参数
ios - 如何在我的应用程序中重用默认的 iPhone 应用程序功能?
iphone - 搜索栏的背景图片在 iOS7 中看起来很奇怪,但在 iOS 6 中看起来很好
iphone - iOS 6.0 MPMoviePlayerController 全屏模式黑色?然后应用程序不再阻止任何操作