Creating an IBOutlet or IBAction from a UIButton within a UITableViewCell subclass in a static UITableView

Hello,


I'm trying to create an IBOutlet from a UIButton that lives in a UITableViewCell subclass in a static UITableView. I've set the custom class for the appropriate cell in my storyboard. I've added the UIButton as a subview of that cell's content view. However, I can't control+drag from the storyboard into my custom cell swift file. Is there any way to accomplish this?


I'm working in Xcode 6.


Thank you.

Answered by ndmeiri in 10270022

I found a workaround:

Instead of control+dragging from the storyboard to the Swift file, I did the following.

  1. Declare an @IBOutlet property in the appropriate Swift file
  2. Drag from the circle plus icon that appears in the gutter to the left of that property to the view on the storyboard that you would like to hook up.


At first, this wasn't working for me because (at least on OS X El Capitan) Xcode 6 would try to resize the Assistant editor divider whenever I dragged from the circle plus icon.

Accepted Answer

I found a workaround:

Instead of control+dragging from the storyboard to the Swift file, I did the following.

  1. Declare an @IBOutlet property in the appropriate Swift file
  2. Drag from the circle plus icon that appears in the gutter to the left of that property to the view on the storyboard that you would like to hook up.


At first, this wasn't working for me because (at least on OS X El Capitan) Xcode 6 would try to resize the Assistant editor divider whenever I dragged from the circle plus icon.

Have same problem here. But not only outlets don't connect. Assistant editor stops to work properly. I try to delete reference to my class and add it again. I try to delete drived data, clean project, restart xcode, restart OSX, restart computer, whole univers! That didn't works. Then i make another user and voila! It's start to work again! Outlets connects, assistant editor edits, univers spinning round'n'round. I decide that is files permissions problem an try to repair permissions for my current user. But that didn't works again.

Is anybody else has this kind of problem? And solutions of cours!

Creating an IBOutlet or IBAction from a UIButton within a UITableViewCell subclass in a static UITableView
 
 
Q