0

TTPhotoViewController のサブクラスを作成しました。iPhone を回転すると、現在の画像も回転しますが、ナビゲーション バーとツールバー (前と次のボタンのあるバー) は回転しません。私のサブクラスでは、shouldAutorotateToInterfaceOrientation:メソッドをオーバーライドしました:

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

willRotateToInterfaceOrientation:duration: e をオーバーライドしようとしましたが、内部にブレークポイントを設定しましたが、このメソッドは呼び出されないようです。

4

2 に答える 2

1

すべてのView Controller、つまりParent View Controllerが回転を許可していることを確認してください。ほとんどの場合、1つ以上のView ControllerがshouldAutorotateToInterfaceOrientationに対してTRUEを返していないために発生しています

于 2011-02-20T22:29:42.200 に答える
1

私は次のように解決しました:

TTPhotoViewControllerは 内にTabBarControllerあり、デフォルトではをTabBarController返しません。したがって、TabBarController をサブクラス化して、次のようにします。YESshouldAutorotateToInterfaceOrientation

@implementation CustomTabBarController

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

@end

小さな詳細を追加します。インターフェイスを回転させようとした最初の試みで、deviceOrientationDidChange:インTTScrollView.mがコメットアウトされていることがわかりました。これは、このコードのコメントを解除すると、スクロールビューがランドスケープ回転で奇妙な動作をするためです。

于 2011-02-21T19:11:51.300 に答える