How to make custom reusable UIView using XIB

suggest change

Following example shows steps involved in initializing a view from XIB.

This is not a complex operation but exact steps need to be followed in order to do it right way first time, avoiding exceptions.

How does loadNibNamed Works

Main steps are:

  1. Create XIB
  2. Create class .h and .m
  3. Define outlets in .h
  4. Connect outlets between .h and XIB

See attached screenshot:

  1. Invoke loadNibNamed inside initWithCoder function of .m file. This is needed to ensure you can directly place UIView object into storyboard / Parent UIView XIB file and define it as your custom view. No other initialization code is needed once you load the storyboard / parent XIB. Your custom view can be added to other views just like other built-in Objective C view objects given in XCode.

Feedback about page:

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


Custom UIViews from XIB files:
* How to make custom reusable UIView using XIB

Table Of Contents
12 UIView
15 UIColor
23 Custom UIViews from XIB files
26 UIImage
28 CALayer
30 NSDate
40 iBeacon
49 NSTimer
79 NSURL
87 AWS SDK
96 NSData
101 Segues
104 EventKit
105 NSBundle
106 SiriKit
111 StoreKit
117 3D Touch
119 Keychain
122 Block
141 AirDrop
144 UISlider
145 Carthage
146 HealthKit
151 plist
157 MVVM
164 UIPhoenix
166 Simulator
168 NSArray
169 OpenGL
175 Core Data
179 MyLayout
180 UIFont
189 Security
200 Codable