假设您有一个 CoolViewController 类。
在你的 CoolAppDelegate.h 中,你需要有这样的东西:
@class CoolViewController;
@interface CoolAppDelegate.h : NSObject <UIApplicationDelegate> {
UIWindow *window;
CoolViewController *viewController;
}
那么你的 CoolAppDelegate.m 将需要
application:applicationdidFinishLaunchingWithOptions:
方法与一些像这样的代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after app launch.
// Add your cool controller's view to the window.
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
}
为避免该错误,您可能还需要通过 Interface Builder 删除对 .xib 文件中指向 rootViewController 的 IBOutlet 的引用。