Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.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
Ios 在rubymotion中强制不同方向的ipad/iphone_Ios_Iphone_Ipad_Rubymotion_Device Orientation - Fatal编程技术网

Ios 在rubymotion中强制不同方向的ipad/iphone

Ios 在rubymotion中强制不同方向的ipad/iphone,ios,iphone,ipad,rubymotion,device-orientation,Ios,Iphone,Ipad,Rubymotion,Device Orientation,我有一个iOS通用应用程序,我需要与以下设备一起使用: 适用于iPad的LandscapeLeft或LandscapeRight iPhone的肖像 以iPad为例,我需要强制应用程序以横向模式打开,即使用户的设备处于纵向模式。当该应用程序仅适用于iPad,而rakefile使用此设置时,它的工作是完美的: app.interface_orientations = [:landscape_left, : landscape_right] 不幸的是,现在,删除该选项后,应用程序默认显示为纵向

我有一个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
我尝试了很多解决方案,但似乎没有一个能达到我想要的效果


谢谢,Vlad要尝试简化一切,您可以使用,这将允许您为每个设备设置不同的设置,这意味着您可以回到应用程序界面方向的简单性,避免所有黑客行为