したがって、ポートレートモードでテーブルビューを表示する UITableViewControler があります。
iPhone を回転させるとすぐに、横向きモードでモーダル ビューを表示したいと考えています。
私が使用するtableViewで:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
現在のモーダル ビューを処理するには:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration {
if((interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft))
{
NSLog(@"Push page view");
PagingViewController *s = [[PagingViewController alloc] initWithNibName:@"PagingView" bundle:nil];
s.hidesBottomBarWhenPushed = YES;
[self presentModalViewController:s animated:YES];
[s release];
}
}
モーダルビューには次のものがあります:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
そして、モーダルビュー自体を却下するには、次のようにします。
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration {
if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
NSLog(@"Dismiss my self");
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
}
これが2回どのように機能するか。iPhone を縦モードから横モードに 3 回回転すると、不正なアクセス エラーが発生します。
エラーの原因がわかりません。ショットを気にする人はいますか?