Skip to content

Instantly share code, notes, and snippets.

@externvoid
Last active December 15, 2015 06:49
Show Gist options
  • Save externvoid/0fcfac4be6bc345ce533 to your computer and use it in GitHub Desktop.
Save externvoid/0fcfac4be6bc345ce533 to your computer and use it in GitHub Desktop.
[2015.01.28 [Swift] カスタムビュー](http://caters.works/2015/01/swift-custom-view/)
掲題のページを参考に作業する際の注意点
1. Swift1.x系統
2. Attribute Inspectorでsize = Freeformを指定
3. @IBOutlet, @IAOutletを適切に設定しないと
fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)
で落ちる。
awakeFromNib: CustomViewのインスタンスにaddSubviewするチャンスを提供する。loadNibNamedが呼ばれるまで、@IBOutlet, @IBActionへはアクセスできない。super.awakeFromNibを呼ばなければいけないが、タイミングは何処でも良い。
UITableView用のカスタムセルとか、作るのに便利!!
***UINibのinstantiateWithOwnerを使ってもloadNibNamedと同じ事ができそう。
iOSのViewはどうやってつくるべき?storyboardとxibの使い分けについて考えをまとめてみた
http://qiita.com/yu_0105/items/4a9c794da4c6261f0f27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment