Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to make outlet connection to a constraint in IB

Tags:

I am running XCode 5 with iOS 7. I need to dynamically change the height constraint of a UITextView prior to its layout. I have seen many postings stating that this can be done by making an outlet connection from the constraint in IB to the source code. I am trying to make the connection from the constraint outlet in IB to the header file of the owning class, but am unable to make the connection - IB does not "highlight" when I drag over the header file, as it does when making connections from other objects like buttons etc.

Has anyone encountered this before? All help is greatly appreciated.

like image 458
johnnyspo Avatar asked Feb 28 '14 04:02

johnnyspo


People also ask

How do I connect an outlet in XCode?

Right click the view name in the Document Outline. Then click the little x by the referencing outlet. Select the view on the storyboard and then click the Connections Inspector. Then you can click the little x to remove an outlet reference.


2 Answers

Here is a picture of me doing it. I'm control-dragging from the constraint to the header file.

enter image description here

In real life I'm more likely to control-drag to the anonymous category in the implementation file, because I don't want an IBOutlet property to be public. So here's a picture of that too. Sorry, this screen shot does not show the cursor: it is at the bottom end of the stretch line.

enter image description here

like image 79
matt Avatar answered Oct 21 '22 04:10

matt


You can make an outlet connection by:

  1. Opening the assistant editor and then ctrl+drag your textview to the respective header file. You should see a property created for the textview.

  2. Manually type @property(nonatomic,retain)IBOutlet UITextField *yourTextField; .Open the assistant editor, drag from the small empty circle(left to the property) to the corresponding control in your view controller.

If you are still not able to make the connection, clean, save your project and then try again.

like image 38
motox Avatar answered Oct 21 '22 04:10

motox