Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 仅在景观中使用_Iphone_Ios_Uitabbar - Fatal编程技术网

Iphone 仅在景观中使用

Iphone 仅在景观中使用,iphone,ios,uitabbar,Iphone,Ios,Uitabbar,当前正在创建iPad应用程序,在登录屏幕后显示一个选项卡栏。到目前为止,我成功地显示了tabbar及其相关视图,唯一的问题是我的tabbar没有以横向模式显示 我希望我的应用程序只在横向方向 请建议我如何将纵向选项卡栏旋转为横向选项卡栏。在所有viewControlle.m文件中使用此方法 -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES

当前正在创建iPad应用程序,在登录屏幕后显示一个选项卡栏。到目前为止,我成功地显示了tabbar及其相关视图,唯一的问题是我的tabbar没有以横向模式显示

我希望我的应用程序只在横向方向


请建议我如何将纵向选项卡栏旋转为横向选项卡栏。

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

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

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

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

试试下面的代码:-For(在uitabar中旋转一个UIViewController)将出现在视图中,并使用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>
1)
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation
{
//对于支持的方向,返回YES。
返回(interfaceOrientation==UIInterfaceOrientationAndscapeLeft | | interfaceOrientation==UIInterfaceOrientationAndscapeRight);
}
2) 更改信息列表
UI支持接口方向
UIInterfaceOrientationAndscapeRight
UIInterface方向和左视图

是,在所有“我的视图”控制器中都这样做。但仍处于横向模式:仅适用于所有方向?@MuditBajpai否,仅选择您需要的方向。您是否检查了所有方向?我查过了。只是这还不够,你必须实现我所回答的方法。@MuditBajpai是的,当然你需要实现shouldAutorotateToInterfaceOrientation:太多了。这个答案只是谜题的一部分,就像你的答案一样。