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.
答案 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.