by shigemk2

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

Markdownちょっとまとめよう

さっきQiitaに投稿したやつ。(From Emacs)

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

<!-- tags RubyMotion -->

http://qiita.com/torshinor/items/26cdb8d3968beafa740c

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

```ruby: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
```

```ruby:about_view_controller.rb
class AboutViewController < UIViewController
  def viewDidLoad
    super
  end
end
```

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

この部分はEmacsから投稿したやつなので無視

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

<!-- tags RubyMotion -->

このように書くことで、ファイル名を表示しつつ、rubyソースコードを表示できる。

```ruby: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
```

Gistとどうやって連携さそうか。