How to connect storyboard to viewcontroller

2019-01-11 16:21发布

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?

2条回答
老娘就宠你
2楼-- · 2019-01-11 16:57

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.

Choose view controller screenshot

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

Choose custom view controller class screenshot

查看更多
做个烂人
3楼-- · 2019-01-11 17:07

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
查看更多
登录 后发表回答