by shigemk2

当面は技術的なことしか書かない

xibファイルを使って表示さす

Ruby - xibファイルを使う。 - Qiita [キータ]

1. xibファイル作成
2. XcodeからInterface Builderを利用してUIをごにょごにょ
3. resoucesにxibファイルを配置
4. コードを弄る
5. rakeしてxibファイルからnibファイルを作成する
app_delegate.rb

class AppDelegate
  def application(application, didFinishLaunchingWithOptions:launchOptions)
    @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
    # このコードからnibファイルをよびだす
    @window.rootViewController = AboutViewController.alloc.initWithNibName("AboutViewController",
                                                                           bundle: nil)
    @window.rootViewController.wantsFullScreenLayout = true
    @window.makeKeyAndVisible
    true
  end
end

about_view_controller.rb

class AboutViewController < UIViewController
  def viewDidLoad
    super
  end
end

そもそもxibファイルを配置するだけでは
Interface Builderで作成したUIをRubyMotionに反映させることはできなくって、
きちんとrubyファイルは作らないといかんのでした。

なお、完成品はこちらです。