iOS4.3以降のバージョンにpresentModalViewControllerを含めるためのコードに問題があります。
iOSバージョンでサポートされている場合にpresentModalViewControllerとpresentViewControllerを使用するために次のコードを使用しています(投稿@Stackoverflowから取得)
if([self respondsToSelector:@selector(presentViewController:animated:completion:)])
[self presentViewController:myView animated:YES completion:^{/* done */}];
else if([self respondsToSelector:@selector(presentViewController:animated:)])
[self presentModalViewController:myView animated:YES];
else
NSLog(@"Oooops, what system is this !!! - should never see this !");
上記は、>5.0および<5.0でテストするとうまく機能します。しかし、私のAppDelegate.miには、アプリケーションが初めて実行されるかどうかを検出するチェックルーチンがあります。
はいの場合は、起動ビューとは異なるビューを最初に開きます。
if (![defaults boolForKey:@"everLaunched"]) {
//NSLog(@"First run");
if([self.viewController respondsToSelector:@selector(presentViewController:animated:completion:)])
[self.viewController presentViewController:infoView animated:YES completion:^{/* done */}];
else if([self.viewController respondsToSelector:@selector(presentViewController:animated:)])
[self.viewController presentModalViewController:infoView animated:YES];
else
NSLog(@"1Oooops, what system is this !!! - should never see this !");
}
どうやら動作しているようですが、アプリを初めて起動したときに警告が表示され、さまざまなデバイスで予期しないエラーが発生するのではないかと心配しています。
Unbalanced calls to begin/end appearance transitions for <ViewController: 0x689da90>.
何か案が?