Can't Hook Up an Outlet Collection in Xcode 6 Using Storyboard

Can't hook up an outlet collection in Xcode 6 using storyboard

You've got it right, you just need to define the array more formally:

@IBOutlet var cardButtons: Array<UIButton>

Now you'll be able to connect the buttons from IB.


The above should work, but still doesn't in Xcode 6 beta 3. A workaround is to use an NSArray until Xcode and Swift can handle this properly:

class ViewController: UIViewController {
@IBOutlet strong var labels: NSArray!

override func viewDidLoad() {
super.viewDidLoad()

for label in self.labels as [UILabel] {
label.textColor = UIColor.redColor()
}
}
}

Wiring up Outlet Collection Trouble

OK I had the same issue and I think I have just found a workaround






1) Do steps one and 2 with the first image




2) Now repeat exactly what you did using the second image - drag and drop just below the first outlet collection (this would simply create a second outlet collection use exactly the same name )




3) Now Xcode won't like it as you have two outletCollections with the same name. Now comment out the first one




4) Now you only have one outlet collection. And it would be wired up to both your images. confirm it by hovering your mouse pointer over the little 'circle' next to the IBOutlet to see your images being highlighted.



This seems to work for me. So hope this helps :-)

Xcode 6 cannot drag ImageView to create outlet collection

Try this step by step.

0/ Check in your Storyboard's Identity Inspector that the UIViewController / UITableViewCell / etc that contains your UIImageViews has the correct class name.

1/ Add the following code in your class:

@IBOutlet var imageViewCollection: [AnyObject]!

2/ From your class, drag your imageViewCollection outlet to your UIImageViews. Or, from Connections Inspector, drag your imageViewCollection outlet to your UIImageViews (see image below).

Sample Image

3/ In your class, replace AnyObject with UIImageView so that your imageViewCollection declaration looks like the following:

@IBOutlet var imageViewCollection: [UIImageView]!

Xcode 6: can't connect any IBOutlet to ViewController

You can also see that the link between the parent view and the custom class is broken (not visible anymore) which is a huge problem.

I had the exact same issue with the app i'm working on actually, updating XCode from 5.xxx to 6.1. The workaround that worked for me was to remove the reference of every view controller and re-add them to the project...

To everyone facing that issue, here's the (annoying) trick :

  • Step 1 : select both .h and .m view controller files
  • Step 2 : remove the reference of those files
  • Step 3 : re-add the files to your project tree
  • Step 4 : open the storyboard, eventually re-build the project and smile

I can understand those things could be reaaally annoying, but it worked for me... Hope it will help someone else !

Can't link to outlet collection in XCode9

I had the same issue. This is the only workaround I could find to get it working is to create the Outlet Collection in code (or create the first one by dragging from the storyboard as you're doing). Then drag from the 'add' icon in the ViewController's line margin back to the objects on the storyboard rather than the usual way around.

Drag from the ViewController to the Storyboard

This also seems to be an alternative way:
https://stackoverflow.com/a/45597939/1320134

In summary, you need create the first outlet collection as you are currently doing, then drag from the newly created 'referencing outlet collection' in the Connections Inspector to the other objects you want to add to the collection in the storyboard.

Can't hook up IBOutlet or IBAction to a View Controller written in Swift after deleting the ObjC version

Seems to be bug in Xcode 6. You can resolve this by Changing the ViewController Custom class in the identity inspector to some another class press return and again change the class to original class you want then press return.

I cannot connect buttons to any outlets or actions

You probably haven't set the Class in the Identity Inspector. Select the view controller in the storyboard for which you want to establish outlets, open the Utilities panel, go to the Identity Inspector, and make sure your "Class" is set.

If you haven't added a second subclass of UIViewController to your project yet, you probably want to cmd-n -> iOS Source -> Cocoa Touch Class and then put in a name and make it a subclass of UIViewController (I am assuming your second view controller is a UIViewController and not a UITableViewController or something else). Then you can set your second view controller's class to this by doing what I described in the first paragraph.

Could not insert new outlet connection: Could not find any information for the class named

Here are some things that can fix this (in increasing order of difficulty):

  • Clean the project (Product > Clean)
  • Manually paste in

    @IBOutlet weak var viewName: UIView!
    // or
    @IBAction func viewTapped(_ sender: Any) { }

    and control drag to it. (Change type as needed.) Also see this.

  • Completely close Xcode and restart your project.

  • Delete the Derived Data folder (Go to Xcode > Preferences > Locations and click the gray arrow by the Derived Data folder. Then delete your project folder.)
  • Click delete on the class, remove reference (not Move to Trash), and add it back again. (see this answer)


Related Topics



Leave a reply



Submit