0

私の最初のビュー コントローラーは LoginViewController です。iOS 6 で自動回転管理をサポートしようとしています。

次のように、shouldAutorotateToInterfaceOrientation の代わりに shouldAutorotate を実装しました。

-(BOOL)shouldAutorotate {
   UIInterfaceOrientation toInterfaceOrientation = [[UIDevice currentDevice] orientation];

   return [DeviceSupport isOrientationSupported:toInterfaceOrientation];
}

shouldAutorotateアプリケーションの起動時に 5 回呼び出されます。toInterfaceOrientation の値は、順番に、iPad の向きを変更せずに、0、0、0、4、4 です。まず、アプリが currentDevice に正しい向きを設定するのに時間がかかるのはなぜですか? そして、なぜ shouldAutorotate が 5 回呼び出されるのでしょうか?

向きが 4 の場合は[DeviceSupport isOrientationSupported:toInterfaceOrientation]true を返します。しかし、私のアプリは回転しません。

私の info.plist で:

Supported interface orientations
=> Item 0: Portrait (bottom home button)
=> Item 1: Portrait (top home button)

Supported interface orientations (iPad)
=> Item 0: Landscape (left home button)
=> Item 1: Landscape (right home button)

何か案が?ありがとう。

4

2 に答える 2

3

コードを次から変更します。

[self.window addSubview:aController.view];

このコードに:

self.window.rootViewController = aController;

また、オリエンテーションをサポートするために次のメソッドを追加します

shouldAutorotate -return YES

supportedInterfaceOrientations - UIInterfaceOrientationMaskPortrait を返します | UIInterfaceOrientationMaskLandscapeLeft;

于 2012-11-08T14:16:32.167 に答える
0

supportedInterfaceOrientations も実装したことを再確認していただけますか?

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}
于 2012-11-08T14:31:32.230 に答える