2011-07-08 23 views
0

私はプログラムベースのiPadを開発しています。 フォームシートモードでフルスクリーンではなく新しいモーダルUIViewControllerを作成しました。 ビューのサイズを変更するために、私は次のコードを使用しました。 MyControllerで ...UIViewControllerのフレームサイズを変更するにはどうすればいいですか?

MyController* controller = [[MyController alloc] init]; 

controller.modalPresentationStyle = UIModalPresentationFormSheet; 

[self presentModalViewController : controller animated: YES]; 

UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; 

if (UIInterfaceOrientationIsPortrait(orientation)) 
    controller.view.superview.frame = CGRectMake(200, 100, 350, 600); 
else 
    controller.view.superview.frame = CGRectMake(100, 200, 600, 350); 

...

、私はdidRotateFromInterfaceOrientationとして、次のcodedsをtaked。

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; 
    if (fromInterfaceOrientation == orientation) 
     return; 
    if (UIInterfaceOrientationIsPortrait(orientation)) 
    { 
     self.view.frame = CGRectMake(0, 0, 350, 600); 
     self.view.superview.frame = CGRectMake(200, 100, 940, 628); 
    } 
    else 
    { 
     self.view.frame = CGRectMake(0, 0, 600, 350); 
     self.view.superview.frame = CGRectMake(100, 200, 600, 350); 
    } 
} 

しかし、画面を回転させると、ビューのサイズが変更されず、スーパービューの幅と高さが予期しない値になります。 私の問題を助けてください。

答えて

0

これをデバッグして実際にどのような方向に向かうのかを試してみてください。

あなたはこれを試しましたか?

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 

    if (UIInterfaceOrientationIsPortrait(fromInterfaceOrientation)) 
    { 
     self.view.frame = CGRectMake(0, 0, 350, 600); 
     self.view.superview.frame = CGRectMake(200, 100, 940, 628); 
    } 
    else 
    { 
     self.view.frame = CGRectMake(0, 0, 600, 350); 
     self.view.superview.frame = CGRectMake(100, 200, 600, 350); 
    } 
} 

はまた、2つのportairtの向きがあることに注意してください。..

関連する問題