Unable to Set Referencing Outlet

15,336

Solution 1

First, make sure the control you're dragging from is the same class as the outlet (in this case, UITextField) or it could be a subclass of that class.

Second, make sure control's parent view is a subclass of the file you're dragging to.

Third, make sure the file you're dragging to is saved. This is the most common problem I run into. Go to the source file you're dragging to and push Cmd+S to save.

Fourth, when in doubt, Cmd+Shift+K to clean, Cmd+B to build, then try again. If that still doesn't work, restart Xcode. And if it's still not working, go back through the checklist.

Solution 2

In my case, to be able to create a referencing outlet,

  1. I had to open the Storyboard.
  2. Click on the top View Controller element (left panel in the Storyboard)
  3. In the Identity Inspector (right panel), I had to select from the list my custom view controller class before I could drag and create the referencing outlet in it.

Solution 3

In my cace,(swift3) 1.right click on the storyboard. 2.Ctrl-Drag from black window and ReferencingOutlet to View on the storyboard. enter image description here

Share:
15,336
vfvfvfvfvfvfvfvfv
Author by

vfvfvfvfvfvfvfvfv

Updated on June 04, 2022

Comments

  • vfvfvfvfvfvfvfvfv
    vfvfvfvfvfvfvfvfv almost 2 years

    I am unable to set a referencing outlet for a text field I have created. I am trying to do this via Ctrl-Drag. Can anyone advise? I have set the delegate as the View Controller. In general, I only have one view which is populated with a few text fields and I have written the following code for the ViewController.h which is what I'm trying to set up as a Referencing Outlet:

    @property (weak, nonatomic) IBOutlet UITextField *userIDText;
    
  • Torge
    Torge over 7 years
    Inmy case Ic ould not drag & drop between the source code file and the interfacebuilder. Maybe because it was too deeply nested. But I could drag & drop from the viewcontroller in the interface builder to its sub elements.
  • Marcy
    Marcy over 4 years
    Exactly what I needed after inadvertently deleting the referencing outlet. :)