Question

Why can't I connect outlets from subviews?

  • Dropped a UIViewcontroller onto storyboard
  • Dropped a subview (UIView) as a custom class CustomSubView : UIView
  • Went into Inspector while subview is selected and changed custom class to CustomSubView
  • I have a couple of labels inside the subview

I tried to drag-drop from storyboard to assistant editor while CustomSubView class header is shown, but I don't get the pop-up to create the outlet. What gives?

I am using Xcode 5.

Was it helpful?

Solution

You can manually write the IBOutlet property declaration in the @interface of the custom view subclass, and assuming you've defined the base class of your subview in IB, then you can drag from the outlet circle in the code back to the control in the scene.

It was answered here: Cannot create outlet connections to subviews in Interface Builder (Xcode 5)

or you can try this:

After typing the property outlet declarations manually in the customview.h file I could ctrl-drag-connect them from there to their corresponding UIlabel objects in the interfacebuilder. Works only in this direction!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top