我知道其中有很多这些,但没有一个解决方案适合我。
情况如下:
AppDelegate.h
#import <UIKit/UIKit.h>
#import "SphereViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) SphereViewController *sphereViewController;
@end
AppDelegate.m
#import "AppDelegate.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.sphereViewController = [[SphereViewController alloc] initWithNibName:@"SphereViewController" bundle:nil];
NSLog(@"%@", self.sphereViewController);
self.window.rootViewController = self.sphereViewController;
[self.window makeKeyAndVisible];
return YES;
}
...
@end
运行此代码时,会记录以下内容:
2014-01-04 21:21:18.691 Sphere[4978:70b] <SphereViewController: 0x10931c600>
2014-01-04 21:25:25.145 Sphere[4978:70b] Application windows are expected to have a root view controller at the end of application launch
为什么即使我正在设置它也会出现根视图控制器错误?
答案 0 :(得分:2)
事实证明,由于某些原因,我的xib中文件所有者的view
属性被设置为GLKView,这显然会导致此错误。
要修复,请确保您的view
属性已正确关联。