简体   繁体   English

如何在故事板中为视图控制器提供“标识符”?

[英]How do I give an “identifier” to a view controller within my storyboard?

The instantiateViewControllerWithIdentifier: method requires that the view controller I pass have an identifier. instantiateViewControllerWithIdentifier:方法要求我传递的视图控制器具有标识符。 I went to my storyboard and clicked on my view controller, but I see no option to set the identifier. 我去了我的故事板并点击了我的视图控制器,但我看不到设置标识符的选项。 Where exactly do I find this option? 我在哪里找到这个选项?

As the Image suggests! 正如图像所示! Hope it helps! 希望能帮助到你!

在此输入图像描述

Then to use it you call: 然后使用它你打电话:

[self.storyboard instantiateViewControllerWithIdentifier:@"YourViewControllerID"];

Updated for XCode 8 and Swift 3. 针对XCode 8和Swift 3进行了更新。

instantiateViewControllerWithIdentifier is now instantiateViewController(withIdentifier:) . instantiateViewControllerWithIdentifier现在是instantiateViewController(withIdentifier :)

Setting the storyboard ID: 设置故事板ID: 在此输入图像描述

In the identity inspector there is a field Storyboard ID . 身份检查器中有一个字段故事板ID You could enter the class name here and then use this identifier in instantiateViewControllerWithIdentifier: . 您可以在此处输入类名,然后在instantiateViewControllerWithIdentifier:使用此标识符instantiateViewControllerWithIdentifier:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用LGSideMenuController推送带有情节提要标识符的视图控制器? - How can I push view controller with storyboard identifier using LGSideMenuController? 如何在情节提要中自定义由标识符实例化并推送到导航堆栈的视图控制器的UINavigationItem? - How to custom in storyboard my view controller's UINavigationItem that is instantiated by identifier and pushed onto navigation stack? 如何在故事板中使用两种不同的布局处理视图控制器? - How do I handle a view controller in my Storyboard with two distinct layouts? 如何启动没有情节提要的另一个视图控制器? - How do I start another view controller with no storyboard? 如何从视图控制器创建故事板segue到自身? - How do I create storyboard segue from a view controller to itself? 如何生成情节提要中定义的视图控制器代码 - how do i generate view controller code defined in a storyboard 如何返回故事板上的第一个视图控制器? - How do I return to the first view controller on a storyboard? 如何从情节提要中的子视图(另一个视图控制器)内的按钮推动新的视图控制器 - How can I push a new View Controller from a button within a subView (another View Controller) in Storyboard 如何在没有xib或情节提要vc标识符的情况下制作视图控制器? - How to make a view controller without a xib or a storyboard vc identifier? iPad Storyboard如何为模态视图控制器提供所需的尺寸 - iPad Storyboard How to give desired size to modal view controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM