1

AViewControllerという名前のViewControllerが1つあります。AViewControllerにボタンがあります。ボタンがクリックされると、BViewControllerと呼ばれる別のViewControllerを表示します。AViewControllerが縦向きの場合は、正常に機能します。向きが横向きの場合、BViewControllerは縦向きで初期化されますが、横向きで表示されます。

これが問題です。BViewControllerを現在の向きで初期化するにはどうすればよいのでしょうか。BViewControllerのinitで[UIScreenmainScreen].boundsを使用します。ただし、デバイスが横向きの場合、境界は横向きではありません。フレームをAViewControllerからBViewControllerに渡すことは知っていますが、機能する可能性があります。しかし、これは良い解決策ではないと思います。それで、もっと良い方法はありますか?

BViewControllerを提示する関数は次のとおりです。

- (void)BtnClicked
{
    BViewController *bvc = [[BViewController alloc] init];
    bvc.delegate = self;
    bvc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentViewController:movie animated:YES completion:nil];
}
4

1 に答える 1

0

私はまだそれを効率的に行う方法を知りません。しかし、私は1つのソリューションを使用して、でwillAnimateRotationToInterfaceOrientationメソッドを手動で呼び出しますviewDidAppear

スニペットは次のとおりです。

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [self willAnimateRotationToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:0];
}
于 2013-11-20T03:39:44.357 に答える