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

Dou*_*ith 33 xcode objective-c storyboard uiviewcontroller ios

instantiateViewControllerWithIdentifier:方法要求I传递的视图控制器具有标识符.我去了我的故事板并点击了我的视图控制器,但我看不到设置标识符的选项.我在哪里找到这个选项?

Gro*_*oot 53

正如图像所示!希望能帮助到你!

在此输入图像描述

然后使用它你打电话:

[self.storyboard instantiateViewControllerWithIdentifier:@"YourViewControllerID"];
Run Code Online (Sandbox Code Playgroud)


Tai*_*sam 10

针对XCode 8和Swift 3进行了更新.

instantiateViewControllerWithIdentifier现在是instantiateViewController(withIdentifier :).

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


Fel*_*lix 5

身份检查器中有一个字段故事板ID.您可以在此处输入类名,然后在中使用此标识符instantiateViewControllerWithIdentifier:.