iphone – UIWindow的’rootViewController’出口在iOS 4.0之前
发布时间:2020-12-14 17:36:31 所属栏目:百科 来源:网络整理
导读:我在iOS 4.0之前版本中遇到以下错误: The 'rootViewController' outlet of UIWindow is not available on releases prior to iOS 4.0. Remove the connection and instead programmatically add the view controller's view to the window after the applic
我在iOS 4.0之前版本中遇到以下错误:
The 'rootViewController' outlet of UIWindow is not available on releases prior to iOS 4.0. Remove the connection and instead programmatically add the view controller's view to the window after the application finishes launching. 我是如何以编程方式执行此操作的? 解决方法
让我们假装你有一个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; } 为避免错误,您可能还需要删除对IBOutlet的引用,该引用通过Interface Builder指向.xib文件中的rootViewController. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |