简体   繁体   中英

Can`t drag @IBOutlet from swift file to storyboard ViewController in Xcode 7.2

I use Xcode 7.2

I can use Control+drag to swift file to create a @IBOutlet
在此处输入图片说明

But I can't drag @IBOutlet in swift file to storyboard. Here I don't use any other key, just drag.
在此处输入图片说明 Actually when I moving mouse to the spot before @IBOutlet, nothing happened and when I trying to drag it a breakpoint added.

1.I`m sure I use the right Class name
2.My project is not in a strange path or name

don't use Control, only drag with mouse from circle icons.You can see in the picture below. Circle icons in red box

在此处输入图片说明

Changed Behavior

The behavior has changed in new versions of Xcode (I'm not certain but it might have been since 7+.). Older versions of the product might still have the gutter shortcut working.

Now you have to either open the Connections Inspector or right-click on the view controller in the Document Outline. Once open, drag from the defined IBOutlet to your UIView subclass (UIButton, UITextField, etc...)

Connections Inspector

检查员

Controller View

控制者

Official Guidance

Search your local help for: Interface Builder Connections Help: Creating an Outlet Connection. You will find these are the only methods that now work. The gutter shortcut does not work.

苹果帮助

Nota Bene:

You can confirm this behavior and other changes to Xcode shortcuts by choosing the following menu Help > Xcode Overview and taking a look at Part V: Building a User Interface , section Connecting Objects In Code .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM