How to make custom reusable UIView using XIB

suggest change

The following steps initialize a view from a xib.

How loadNibNamed works

Main steps:

  1. Create the xib.
  2. Create the class .h and .m files.
  3. Define outlets in the .h file.
  4. Connect the outlets between the class and the xib.

See attached screenshot:

  1. Call loadNibNamed from initWithCoder: in the .m file so a storyboard or parent xib can place this view and set its class. The loadNibNamed call itself is not shown here. Loading the same class from inside initWithCoder: loops forever if the xib’s root view is that class. The usual guard is a flag, or a xib whose root view is a plain UIView with the custom class as File’s Owner. This page does not show that guard.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents