Ios 在rubymotion中强制不同方向的ipad/iphone
我有一个iOS通用应用程序,我需要与以下设备一起使用: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] 不幸的是,现在,删除该选项后,应用程序默认显示为纵向
- 适用于iPad的LandscapeLeft或LandscapeRight
- iPhone的肖像
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要尝试简化一切,您可以使用,这将允许您为每个设备设置不同的设置,这意味着您可以回到应用程序界面方向的简单性,避免所有黑客行为