xcode5 add new referencing outlet

2020-02-11 05:04发布

问题:

Hi I have Just Update my xcode to xcode5, but I have no idea how to add new referencing outlet using xcode 5 by ctrl-drag and drop the label or buttons just like previous what I did in xcode 4.5

Thank you in advance

回答1:

Open your storyboard and click on the editor button (seems like a suit) and select the .h associate to your view :

Then, ctrl drag the UI element from the storyboard or xib on your header file or your .m between @interface and @end.

XCode will show you a pop-up with some options :

And you will obtain the following code :

@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIScrollView *myScrollView;

@end


回答2:

Today, I also encountered this problem. And I resolved it like this:



回答3:

Start by selecting the ViewController you want the outlet in your storyboard.

Then click on the suite symbol on the upper right and make sure the storyboard is on the left and the header of the custom UIViewController is on the right, you can click on automatic on top of the right file to get some help with this.

Then ctrl drag the label from the storyboard on the left between @interface and @end in the header on the right.



回答4:

I was missing the obvious myself here. To add a new Referencing Outlet (I'm using XCode 9.0) I did the following:

  1. Ensure the storyboard and header file are both open and visible
  2. Right-click on the control and drag the + symbol by New Referencing Outlet to the line in your header file where you want the new variable reference.


标签: xcode5