1

Rubymotionを使ったユニバーサルアプリを持っていますが、iPhone版とiPad版でUIの設定が大きく異なります。

主なものは、iPhone ではポートレートのみをサポートし、iPad はランドスケープのみをサポートします。

可能であればRakefileで何かを設定することでこれを行いたいと思います.代替手段はdelagateメソッドで何かを行うことですが、可能であれば設定ファイルで方向設定を設定したいと思います.

Motion::Project::App.setup do |app|
  #app settings
  app.name = 'xxxxx'
  app.version = "0.xxxx"
  app.device_family = [:iphone, :ipad]
  app.interface_orientations = [:portrait]
end

編集:

ハモンの答えがどのように機能したかに関するいくつかの更新。UINavigation で shouldAutorotate が false を返すと、iPad バージョンで奇妙な現象が発生し、向きが横向きに設定されていても、iPad バージョンの一部でビューのコンテンツが縦向きに表示され、shouldAutorotate に true を返すとうまくいきました。

4

2 に答える 2

2

私の知る限り、Rakefile でそれを行うことはできません。両方の向きを提供することを指定してから、向きがサポートされているかどうかをプログラムで iOS に伝える必要があります。

UIViewControllers および/または UINavigationController(s) は次のようになります。

def ipad?
  NSBundle.mainBundle.infoDictionary["UIDeviceFamily"].include?("2")
end

def shouldAutorotate
  false # I think?
end

def supportedInterfaceOrientations
  if ipad?
    UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight
  else
    UIInterfaceOrientationMaskPortrait
  end      
end

def preferredInterfaceOrientationForPresentation
  ipad? ? UIInterfaceOrientationMaskLandscapeLeft : UIInterfaceOrientationMaskPortrait
end

このコードはテストしていませんが、過去に同様のものを使用しました。三項 (最後の方法で行ったように) または通常の を使用できますif

于 2013-07-11T19:38:16.027 に答える