【问题标题】:Creating ViewController in landscape orientation on iPhone在 iPhone 上以横向创建 ViewController
【发布时间】:2012-04-23 21:04:45
【问题描述】:

在我的应用程序中,我需要在用户单击按钮时加载新的视图控制器。我从 XIB 文件加载它。它是根据 XIB 文件中设置的 ORIENTATION 出现的(在视图的“模拟指标”中),而不是实际的设备方向。

我怎样才能有问题地改变视图的方向?

注意: 加载视图控制器后,它会立即处理正确的方向更改事件并在旋转时自动调整所有正确的大小。

已编辑: 我通过为横向添加另一个 XIB 文件来使其工作:

[self initWithNibName: ( UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation]) ? @"tfdSearchViewController_iPhone_Landscape" : @"tfdSearchViewController_iPhone" )]

但这很傻,因为两个xib文件之间的唯一区别是“方向”值。

【问题讨论】:

    标签: ios orientation xib viewcontroller


    【解决方案1】:
    [[UIDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeRight];
    

    更改设备方向只需将其设置为您想要的

    【讨论】:

    • 我不想更改设备方向。我想根据设备方向在 XIB 中设置方向。喜欢self.view.orientation = [[UIDevice currentDevice] orientation]。但是view.orientation 不存在。
    • view.transform = CGAffineTransformMakeRotation(M_PI);我希望这能解决你的问题
    猜你喜欢
    • 2010-10-31
    • 2013-05-24
    • 1970-01-01
    • 2013-10-03
    • 1970-01-01
    • 1970-01-01
    • 2013-01-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多