4

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.

プログラムでこれを行う方法と場所は?

4

1 に答える 1

4

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 への参照も削除する必要があります。

于 2010-11-09T11:19:09.880 に答える