How to connect storyboard to viewcontroller

2019-01-11 16:37发布

问题:

In the new xcode 5 how do in interface builder you use to have a drop down menu there to connect your storyboard viewcontrollers to your classes how is this done now?

回答1:

Unless I'm misunderstanding what you're asking, it's still there. Here are the steps to assign a custom view controller class to your view controller:

  1. Choose your view controller in the list of scenes on the left side.

  1. Choose the Identify Inspector on the right side.
  2. Choose the custom view controller class from the Class list.



回答2:

1、manual creating a Cocoa Class to the project

2、open the story board, draw a view controller from tool box to the storyborad

3、click the controller you draw into the storyboard, and specify the 'Customer Class' to the class you create in step 1

4、if you use XIB, nibName could be the controller name, else if you use StoryBoard, you need set a storyboard id for your controller in your storyboard panel, and you can use the id and the storyboard in your superController when you want to new a controller

// XIB
var viewController = UIViewController(nibName: "ViewController", bundle: nil)
// StoryBoard
var viewController = storyboard.instantiateViewController(withIdentifier: "The-Storyboard-ID-You-Set") as! ViewController