iphone - 如何在标签栏应用程序中将 View 旋转为横向

标签 iphone ios cocoa-touch

我有一个基于标签栏的应用。

我在 Interface Builder 中构建了 2 个 View ,一个是纵向模式,另一个是横向模式。

现在,我想要 iPod 应用程序之类的东西。我希望横向 View 是全屏的,并隐藏标签栏和状态栏。

我的工作基础是:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                duration:(NSTimeInterval)duration { 
    if (self.landscape) {
        if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
        {
            self.view = self.portrait;
            self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(360));
        }
        else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
        {
            self.view = self.landscape;
            self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
        }
        else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
        {
            self.view = self.landscape;
            self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
        }
        else
        {
            self.view = self.portrait;
            self.view.transform =  CGAffineTransformMakeRotation(degreesToRadian(-180));
        }
    }
}

但是所有的工作都很乱。横向 View 未正确填充该区域,并且控件位于错误的位置,与最初的设计不同。

此外,我还没有找到隐藏其他所有内容的方法...

最佳答案

查看 Apple 的“AlternateViews”示例代码。

基本思想是您可以通过通知检测设备的物理方向,然后“模态”激活一个新的 View Controller 并让它请求全屏。您可以通过让 shouldAutorotate... 仅针对一个方向返回 YES 来禁用界面旋转,因为您是通过通知手动执行所有这些操作。当您更改物理方向时,您的模态视图 Controller 要么显示要么关闭。

关于iphone - 如何在标签栏应用程序中将 View 旋转为横向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/534405/

相关文章:

iphone - iOS 从表格 View 单元格拖放到 ImageView

ios - IB - 将 UIView 添加到 UITableViewController?

iphone - 使用适用于 iOS 的 v3.1 Facebook SDK 进行 FQL 查询以获取生日和电子邮件

ios - Swipeview 滞后于项目更改

iOS 推送通知 keyId

objective-c - NSFetchRequest setPropertiesToGroupBy : return all entities that match? 是否

iphone - 如何向可自定义的 UITabBar 添加徽章?

iPhone 4 是否有绝对确定的方式让 NSTimer 长期运行

iphone - UIViewController 和 UINavigationController 的问题

ios - 类型转换大 NSInteger float 问题