【问题标题】:Force different orientation for ipad/iphone in rubymotion在 ruby​​motion 中强制 ipad/iphone 的不同方向
【发布时间】:2013-12-11 08:56:56
【问题描述】:

我有一个 iOS 通用应用程序,我需要将它用于:

  • iPad 的 LandscapeLeft 或 LandscapeRight

  • iPhone 肖像

我们以 iPad 为例,我需要强制应用以横向模式打开,即使用户的设备处于纵向模式。当应用程序仅适用于 iPad 并且 rakefile 使用此设置时,这是完美的:

app.interface_orientations = [:landscape_left, : landscape_right]

不幸的是,现在,删除该应用后,该应用默认以纵向模式显示。我试图通过覆盖 UIViewController.rb 中的以下方法来改变这一点。这适用于模拟器,但不适用于我的设备:

  def shouldAutorotate
    # Block AutoRotation if the interfaces is CORRECT
    # Else allow IT
    if Device.ipad? # BubbleWrap gem method 
      if App.shared.interfaceOrientation == UIInterfaceOrientationLandscapeLeft
        return false
      elsif App.shared.interfaceOrientation == UIInterfaceOrientationLandscapeRight
        return false
      else
        return true
      end
    elsif Device.iphone?
      if App.shared.interfaceOrientation == UIInterfaceOrientationPortrait
        return false
      else
        return true
      end
    end
  end

  def viewDidAppear(animated)
    # Change the orientation after the view Appeared
    if Device.ipad?
      App.shared.setStatusBarOrientation(UIInterfaceOrientationLandscapeLeft)
    elsif Device.iphone?
      App.shared.setStatusBarOrientation(UIInterfaceOrientationPortrait)
    end
  end

我尝试了很多解决方案,但似乎都没有按照我想要的方式工作。

谢谢,弗拉德

【问题讨论】:

    标签: ios iphone ipad rubymotion device-orientation


    【解决方案1】:

    要尝试简化一切,您可以使用motion-schemes wrapper,它可以让您为每台设备设置不同的设置,这意味着您可以回到app.interface_orientations 的简单性并避免所有黑客攻击。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-14
      • 2011-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多