1

他のviewControllerを持っている私のviewControllerでは、iOS 5ではwillAnimateRotationToInterfaceOrientationメソッドを呼び出すので問題なく動作します。デバイスを回転させると、iOS が を呼び出しwillAnimateRotationToInterfaceOrientation、アプリは正しく動作しますが、アプリを最初に起動すると、動作しません。次にwillAnimateRotationToInterfaceOrientation、viewWillAppear を呼び出そうとしますが、役に立ちません。

プログラムなどで呼び出すにはどうすればよいwillAnimateRotationToInterfaceOrientationですか?

4

1 に答える 1

2

willAnimateRotationToInterfaceOrientation:duration:デバイスによってのみ呼び出されるべきいくつかのメソッドの 1 つです。唯一特別なことは呼び出されたときです。したがって、その機能を別のメソッドに抽出すると、その機能を好きなように呼び出すことができるはずです (この場合は でviewWillAppear)。

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [self prepareToRotate];
}

-(void)prepareToRotate {
    // existing functionality goes here
}

toInterfaceOrientationまたはを使用する場合durationは、 のパラメータとしてそれらも含める必要があることに注意してくださいprepareToRotate

于 2013-04-15T13:59:51.717 に答える