Unable to connect IBOutlet from storyboard to UIView subclass

We see this issue sometimes too since Xcode 8, and assume this is a Xcode bug.

As a workaround:

  • Write the outlet in code @IBOutlet weak var myUiElement: UIView!

  • Ctrl + Drag from your outlet to the UI element in the Storyboard


Its basic, but easy to overlook. Make sure the view controller you are dragging the outlet to is labeled as the custom class you created.

enter image description here


Create an outlet like this in Objective-C

@property (nonatomic, weak) IBOutlet UIView *view;

or as in swift 3

@IBOutlet weak var instruction: UILabel?

and then connect it as given in this image.

enter image description here

Sometimes the normal way of connecting action and outlet doesn't work due to subclassing. This way comes handy for such situations.