Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to set referencing outlet in Interface Builder without Ctrl-Drag

So I'm just trying to create a very simple app for demo purposes here:

  • Created a Single View Application, using storyboards
  • Added a UIView to the storyboard
  • Added the following code to my controller's header file:

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

Now, I understand that I can link the UIView to the controller by:

  • arranging my code such that the header file is next to the storyboard
  • holding down Ctrl key and dragging it to the property in the header file

My question is this: can I do this without Ctrl-drag? And if so, how?

More specifically - it's annoying to have to put both my header file and storyboard on screen at the same time, and it seems there should be a way to make this connection without doing so.

I also understand that I can manually place the view by creating it inside my controller's viewDidLoad function, but I'd really like to use the interface builder to simplify / visualize things.

Edit: Is the answer to my question affected whether I use storyboards or xib/nib files? (I'd switch to use the one where it works)

like image 544
Krease Avatar asked Jun 28 '12 18:06

Krease


2 Answers

you should be able to right click the element, and drag the "referencing outlet" item to the view's "File's Owner" in interface builder. There, it will give you a list of all available IBOutlets (matching the object's type).

like image 154
Dima Avatar answered Jan 03 '23 14:01

Dima


In addition to Dima's answer, you can just as well use the Connection inspector in the Utilities pane

Connection Inspector

like image 20
Novakedy Avatar answered Jan 03 '23 14:01

Novakedy