2

したがって、ポートレートモードでテーブルビューを表示する 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 回回転すると、不正なアクセス エラーが発生します。

エラーの原因がわかりません。ショットを気にする人はいますか?

4

1 に答える 1

0

私が考えることができる最も簡単な方法は、-shouldAutorotate... を実装し、モーダル ビューを閉じて、NO を返して回転を中止することです。おそらく、同時実行の問題を回避するにはそれで十分でしょう。この提案が気に入らない場合は、NSNotificationCenter をご覧ください。

于 2011-06-14T21:44:52.887 に答える