4

私はストーリーボードを使用しており、UITabBarController に UINavigationController が埋め込まれています。ビュー コントローラーをプッシュし、このビュー コントローラーから UIViewController を使用して MODAL UINavigationController を提示します。

問題は、モーダル ビューの前のすべてのビューが回転できないときに、モーダル ビュー コントローラーが回転できることです。回転を許可するモーダル ナビゲーション コントローラーを停止するにはどうすればよいですか?

私は追加しようとしました:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

ありがとう

4

1 に答える 1

5

UINavigationController をカテゴリ化してみてください

@implementation UINavigationController (Rotation_IOS6)

-(BOOL)shouldAutorotate
{
    return [[self.viewControllers lastObject] shouldAutorotate];
}

-(NSUInteger)supportedInterfaceOrientations
{
    return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
于 2012-11-11T19:09:58.097 に答える