“rootViewController” UIWindow 的出口在 iOS 4.0 之前的版本中不可用

发布于 2024-09-29 06:44:53 字数 313 浏览 5 评论 0原文

我在 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.

如何以及在哪里以编程方式执行此操作?

I am getting the following error on pre-iOS 4.0 builds:

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.

How and where do I do this programmatically?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云醉月微眠 2024-10-06 06:44:53

假设您有一个 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;
}

为了避免错误,您可能还需要删除对指向 rootViewController 的 IBOutlet 的引用通过 Interface Builder 在您的 .xib 文件中。

Let's pretend you have a CoolViewController class.

Inside your CoolAppDelegate.h you need to have something like this:

@class CoolViewController;

@interface CoolAppDelegate.h : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    CoolViewController *viewController;
}

Then your CoolAppDelegate.m would need the

application:applicationdidFinishLaunchingWithOptions:

method with some code like this:

- (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;
}

To avoid the error you'll probably need also to remove the reference to the IBOutlet that points to the rootViewController in your .xib file via Interface Builder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文