全方向で動作するアプリがあります。
iOS 6の場合、私は使用します
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
そしてiOS 5の場合
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
この部分は機能しているようです。
次に、回転アニメーションを停止したいので、これらのメソッドを実装します。
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
[UIView setAnimationsEnabled:NO];
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[UIView setAnimationsEnabled:YES];
}
すべて問題ありませんが、UIAlert を表示してからデバイスを回転させると、背景の黒い影が間違った方向に表示されます。
これは iOS 6 でのみ発生し、iOS 5 ではなく、実際のデバイスとシミュレーターで発生し、回転がアニメーション化されないようにした場合にのみ発生します。
何か案が?
編集: ここで私の rootViewController
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Other things
self.rootViewController = [[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]] autorelease];
self.window.rootViewController = self.rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
ウィンドウは NIB に保存されます。