4

サイドバー ビューとして子 UIViewController を持つ UIViewController を表示する UINavigationController を使用して UI を作成しようとしています。横方向では、右側のストライプになります。縦向きに回転すると、UINavigationController が自動回転し、他のすべてがそれとともに回転する間、物理的な側面にとどまります。したがって、縦向きの場合、サイドバーはボトムバーになります。

モックアップを見てください。 UI モックアップ

さて、これを行う方法は?に戻っNOshouldAutorotateToInterfaceOrientation:interfaceOrientation:も、そのサイドバーの回転は止まりません:-/

4

4 に答える 4

2

次のように、View Controller の autorotation 検出メソッドでビューのフレームおよび/または変換を変更します。

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)to duration:(NSTimeInterval)duration
{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:duration];

    // Calculate the new frame and rotation angle of the view
    // e. g.:

    if (UIInterfaceOrientationIsPortrait(to)) {
        theView.frame = CGRectMake(0, 924, 768, 100);
        theView.transform = CGAffineTransformIdentity;
    } else {
        theView.frame = CGRectMake(924, 0, 100, 768);
        theView.transform = CGAffineTransformMakeRotation(M_PI / 2);
    }

    [UIView commitAnimations];
}
于 2012-08-10T06:40:26.953 に答える
1
CGAffineTransform t;
//You have to caculate the angel of view controller rotating    
CGFloat rotateAngel = M_PI / 2;//replace 'M_PI / 2' with your view controllers rotation angel
t = CGAffineTransformMakeRotation(-rotateAngel);
[view setTransform:t];
于 2012-08-10T06:37:59.067 に答える
1

サイド ビューをナビゲーション コントローラー ビューから分離することは可能ですか (子ビューにしないでください)。そのため、回転をより細かく制御できます。とにかく、ビュー内で画像を回転させることができます。

于 2012-08-27T19:44:50.017 に答える
1

1 つの画面に 2 つのビュー コントローラーが混在しているため、自動回転を使用してこれを行うことはできません。親ビュー コントローラーと子ビュー コントローラーの両方で自動回転をオフにし、回転を検出したら、必要な変換を自分で行います。自動回転は、コントローラー ビュー (他のビュー コントローラーによって制御されるサブビューを含む) の下にあるすべてのビューを回転させます。

別の方法として、(willRotateToInterfaceOrientation を受け取ったときに) 最初にビューをスライドさせてから、didRotateFromInterfaceOrientation を受け取ったときに正しい方向にスライドして戻すこともできます。

于 2012-08-29T09:05:40.023 に答える