当前正在创建iPad应用程序,该应用程序在登录屏幕后显示一个Tabbar。到目前为止,能够成功显示标签栏及其相关视图,唯一的问题是我的标签栏没有出现在横向模式下。

我只希望横向应用程序。

请建议我如何将纵向标签栏旋转到横向标签栏。

最佳答案

尝试以下代码:-对于(在UITabBar中旋转一个UIViewController)在viewWillAppear中并使用CGAffineTransform

    - (void)viewWillAppear:(BOOL)animated; {
       //-- Adjust the status bar
       [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
       //-- Rotate the view
       CGAffineTransform toLandscape = CGAffineTransformMakeRotation(degreesToRadian(90));
       toLandscape = CGAffineTransformTranslate(toLandscape, +90.0, +90.0 );
       [self.view setTransform:toLandscape];
    }


更改所有项目:-复制并粘贴到所有ViewController中

1)

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations.
        return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }



   2) Change in Info.Plist

    <key>UISupportedInterfaceOrientations</key>
        <array>
            <string>UIInterfaceOrientationLandscapeRight</string>
            <string>UIInterfaceOrientationLandscapeLeft</string>
        </array>

10-07 23:31