0

アプリを ios6 に変換していますが、回転の問題が発生しています。デバイスを回転させたときに呼び出されるメソッドを教えてください

4

4 に答える 4

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


- (void)doLayoutForOrientation:(UIInterfaceOrientation)orientation { 
if (UIInterfaceOrientationIsPortrait(orientation)) 
{
//set the frames here
}
else 
{
//set the frames here
} 
}

これらは、iOS 6の新しい方法であり、向きに従ってフレームを設定できます。それがあなたに役立つことを願っています。

于 2012-11-20T05:24:46.313 に答える
0
 -(NSUInteger)supportedInterfaceOrientations

{
    return UIInterfaceOrientationMaskAll;
}

-(void)viewWillLayoutSubviews
{
if([self interfaceOrientation] == UIInterfaceOrientationPortrait||[self interfaceOrientation] ==UIInterfaceOrientationPortraitUpsideDown)
    {
     //set the frames here
    }
    else if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft||[self interfaceOrientation] == UIInterfaceOrientationLandscapeRight)
    {
      //set the frames here
    }
}

これを使用すると、デバイスの向きを変更するたびに上記のメソッドが呼び出されます。

于 2012-11-19T06:48:58.943 に答える
0

- (BOOL) shouldAutorotate -(NSUInteger)supportedInterfaceOrientations

以上がiOS 6に追加された新機能です。

于 2012-11-19T06:07:36.703 に答える
0

これらのメソッドで回転を処理します

-(BOOL) shouldAutorotate
{
    return NO;
}

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

回転中のいくつかのビューで、UIImagePickerController などを必要としない場合は、子クラスを作成して最初のメソッドをオーバーライドします。

于 2012-11-22T11:29:16.727 に答える