首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >怪异景观UITabBarController应用程序启动

怪异景观UITabBarController应用程序启动
EN

Stack Overflow用户
提问于 2009-07-17 00:06:44
回答 2查看 1.6K关注 0票数 0

我的应用程序非常简单,但在启动时我遇到了一些问题。我在Info.plist中设置了美化环境,但它似乎忽略了订单。事实上,当应用程序加载时,仿真器是美化的,但它在纵向模式下返回。

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

  • MainViewController (扩展UITabBarController只是为了覆盖shouldAutorotateToInterfaceOrientation:)
    • 三个扩展UITableViewControllers作为选项卡(还有正确设置shouldAutorotateToInterfaceOrientation的选项卡)

如果我强迫设备的方向去景观,用:

[UIDevice currentDevice setOrientation: UIInterfaceOrientationLandscapeRight];

然后在一个瞬间的模拟器闪烁在肖像模式,然后它去美化。问题是这样,自动旋转动画就开始了,这是我不能说的。我只想要一个固定的,美化的应用程序。

有什么线索吗?我是不是遗漏了什么?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2009-07-17 08:11:35

试试看以下几点。不知道为什么对你不起作用

1)设置密钥UIInterfaceOrientation

到UIInterfaceOrientationLandscapeRight文件中的.plist文件

2)重写您的UITabBarController shouldAutorotateToInterfaceOrientation()方法;在下面的代码中,只处理制表符0和一个,并且只处理一个控制器:如果您有一个导航控制器,并且希望控制堆栈上的不同控制器,则必须相应地修改代码。

代码语言:javascript
复制
- (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)设定

代码语言:javascript
复制
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

在委托的applicationDidFinishLaunching()方法中,只需要模拟器,而不是设备上。

3)在控制器中添加以下shouldAutorotateToInterfaceOrientation(method)

代码语言:javascript
复制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
   return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

4)在您的设备上运行应用程序,并通过使用硬件菜单项,向左旋转和向右旋转来验证它是否正常工作。您应该在景观模式下看到显示。

票数 0
EN

Stack Overflow用户

发布于 2010-03-24 15:02:01

也许这能帮到http://www.dejoware.com/blogpages/files/iphone_programming_landscape_view_tutorial.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1140914

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档