8

私のアプリはiOS6GMシミュレーターでは自動回転しませんが、デバイス上の同じバージョンのiOSでは自動回転します。これはシミュレーターのバグでしょうか?アプリは非推奨の自動ローテーションメソッドを使用していますが、デバイス自体で正常に動作しているため、シミュレーターAPIが異なるのではないかと思います。

4

4 に答える 4

15

didFinishLaunchingWithOptions:非推奨のrotateメソッドでも機能するはずですが、メソッドに以下を追加する必要があります。

self.window.rootViewController = yourRootViewController;

これはwindow、回転通知を送信するViewControllerをメインに指示します。これはiOS6.0SDKの新機能です。

于 2012-09-27T13:34:27.777 に答える
11

これは、アプリを再び機能させるために追加したものです。

// Tell the system what we support
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

// Tell the system It should autorotate
- (BOOL) shouldAutorotate {
    return YES;
}

// Tell the system which initial orientation we want to have
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}
于 2012-09-13T14:04:00.877 に答える
0

以下を追加するだけでは、シミュレーターで機能させるには不十分でした。

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (BOOL) shouldAutorotate {
    return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}

これを機能させるために、appDelegateクラスのdidFinishLaunchingWithOptions関数内に次のものも追加しました。

self.window.rootViewController = viewController;

この追加後、次のエラーが発生しなくなりました。 アプリケーションの起動時に、アプリケーションウィンドウにルートビューコントローラーが必要です。

于 2012-09-26T18:06:02.747 に答える
0
- (BOOL)shouldAutorotate {
    return NO;
}

appplistファイルでルートビューコントローラーでサポートされている回転を縦向きのみに設定します。

于 2013-01-25T06:23:53.280 に答える