简体   繁体   中英

Xib Instantiation of a custom UIView

Use-case:

  1. A Xib is defined with a single simple UIView
  2. A custom view class was created ( inheriting from UIView )
  3. In order to change the class used for the view defined @ [1] I change the XiB view identity from UIView to ~MyCustomView~

Problem:
I was expecting that 'MyCustomView::initWithFrame' will get called, apparently, it doesn't!!

How can I make custom classes instantiated while the 'XiB' is being loaded ?

Any help will be appreciated.

你应该覆盖initWithCoder:用于初始化和awakeFromNib用于当视图连接所有出口和操作时。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM