I cannot connect buttons to any outlets or actions

时间:2015-07-08 15:45:43

标签: ios swift xcode6

On my swift project, I have two view controllers. On the second view controller, I cannot create any outlets, actions, or outlet collections with the buttons. When I drag the buttons to ViewController.swift, I can't place the button anywhere to create an outlet or an action.

When I write out the action / outlet with @IBAction etc. I can't connect it to my buttons on the second view controller.

1 个答案:

答案 0 :(得分:2)

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.

相关问题