【问题标题】:UITabbar only in LandscapeUITabbar 仅在横向
【发布时间】:2012-02-23 04:52:24
【问题描述】:

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

我只希望我的应用程序是横向的。

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

【问题讨论】:

    标签: iphone ios uitabbar


    【解决方案1】:

    试试这段代码:- For(Rotate one UIViewController in UITabBar) In viewWillAppear and use 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>
    

    【讨论】:

      【解决方案2】:

      在您的所有 viewControlle.m 文件中使用此方法

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

      【讨论】:

      • 是的,在我所有的视图控制器中都这样做了。但仍处于横向模式
      【解决方案3】:

      除了在所有相关的视图控制器中实现 shouldAutorotateToInterfaceOrientation: 之外,请确保您的 myProjectName-info.plist 文件指定您选择的支持的界面方向:

      您也可以通过在项目导航器中选择您的项目(视图 > 导航器 > 显示项目导航器)来设置此设置,选择您的目标,然后选择“摘要”选项卡,然后按所需的方向按钮:

      【讨论】:

      • :只对所有方向都足够?
      • @MuditBajpai 不,只选择您需要的方向。
      • 你检查过这个所有方向吗?我检查过。仅此还不够,您必须实现我所回答的方法。
      • @MuditBajpai 是的,当然你也需要实现 shouldAutorotateToInterfaceOrientation: 。这个答案只是谜题的一部分,就像你的一样。
      猜你喜欢
      • 2012-08-24
      • 1970-01-01
      • 1970-01-01
      • 2012-10-12
      • 1970-01-01
      • 2021-07-06
      • 2012-03-10
      • 2012-12-31
      • 1970-01-01
      相关资源
      最近更新 更多