Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.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 AbbarController应用程序启动_Iphone_Cocoa Touch_Uitabbarcontroller_Landscape - Fatal编程技术网

Iphone AbbarController应用程序启动

Iphone AbbarController应用程序启动,iphone,cocoa-touch,uitabbarcontroller,landscape,Iphone,Cocoa Touch,Uitabbarcontroller,Landscape,我的应用程序很简单,但在启动时遇到了一些问题。我在Info.plist中设置了景观,但它似乎忽略了顺序。事实上,当应用程序加载时,模拟器是景观化的,但随后它会以纵向模式返回 这是视图和控制器的层次结构: MainViewController扩展UITabBarController只是为了覆盖shouldAutorotateToInterfaceOrientation: 三个扩展的UITableViewController作为选项卡,它们还正确设置了shouldAutorotateToInterf

我的应用程序很简单,但在启动时遇到了一些问题。我在Info.plist中设置了景观,但它似乎忽略了顺序。事实上,当应用程序加载时,模拟器是景观化的,但随后它会以纵向模式返回

这是视图和控制器的层次结构:

MainViewController扩展UITabBarController只是为了覆盖shouldAutorotateToInterfaceOrientation: 三个扩展的UITableViewController作为选项卡,它们还正确设置了shouldAutorotateToInterfaceOrientation。 如果我强制设备的方向与以下方向平行:

[[UIDevice currentDevice]设置方向:UIInterfaceOrientation和scapeRight]

然后模拟器在纵向模式下闪烁一瞬间,然后进入景观。问题是,通过这种方式,自动旋转动画开始了,这是我无法忍受的。我只需要一个固定的,景观应用程序


有什么线索吗?我错过什么了吗

试试下面的方法。不知道为什么它不适合你

1设置按键UIInterfaceOrientation 要在.plist文件中创建界面方向和scapeRight

2覆盖您的UITabBarController shouldAutorotateToInterfaceOrientation方法;在下面的代码中,只处理选项卡0和1,并且只处理一个控制器:如果您有一个导航控制器,并且希望控制堆栈上的不同控制器,则必须相应地修改代码

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    BOOL tabZeroController = [[[self.viewControllers objectAtIndex:0] visibleViewController] isKindOfClass:[YourTabZeroTableViewController class]];

    BOOL tabOneController = [[[self.viewControllers objectAtIndex:1] visibleViewController] isKindOfClass:[YourTabOneTableViewController class]];


    if(self.selectedIndex == 0 && tabZeroController)
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);

    if(self.selectedIndex == 1 && tabOneController)
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);

    return NO;

}
2设置

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
在代理的应用程序中,仅模拟器需要IDFinishLaunching方法,而设备上不需要

3在控制器中添加以下shouldAutorotateToInterfaceOrientationmethod

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
   return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
4在您的设备上运行应用程序,并使用硬件菜单项“向左旋转”和“向右旋转”验证其是否正常工作。您应该可以在横向模式下看到显示屏。

这可能会有所帮助

我想我在您的UIT中遗漏了一些东西阿巴斯控制器应该自动旋转指针界面定向实现。因此,仅当当前选定选项卡的viewcontroller是我为tabbarcontroller设置的其中一个viewcontroller时,您才希望返回YES?是的,基本上,如果您希望有一种混合行为,其中一些选项卡控制器仅为landascape,而其他选项卡控制器的行为可能不同,这就是一个想法。如果情况并非如此,则在该方法中,只需返回interfaceOrientation==UIInterfaceOrientationAndscapeRight;所以这正是我现在正在做的。。真奇怪。我会继续调查的,真的很奇怪。它适用于我的iPhone 3G和3GS。