gpt4 book ai didi

ios - Storyboard实例化 View Controller ,崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:51:05 25 4
gpt4 key购买 nike

我已经在 iOS5 中使用 Storyboard创建了一个项目。我将一个 UIViewController 拖到 Canvas 上,设置标识符和自定义类。当我尝试使用此方法时,代码在此行崩溃。我想不通,为什么?

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

最佳答案

An identifier string that uniquely identifies the view controller in the storyboard file. You set the identifier for a given view controller in Interface Builder when configuring the storyboard file. This identifier is not a property of the view controller object itself and is only used by the storyboard file to locate the view controller.

If the specified identifier does not exist (or is nil) in the storyboard file, this method raises an exception.

您确定标识符相同吗?

编辑:

这样做的结构应该是这样的

UIViewController *temp = [[self storyboard] instantiateViewControllerWithIdentifier:@"ImagePickerViewController"];

[self presentModalViewController:temp animated:YES];

对于 Storyboard上的 View Controller ,在显示属性检查器下 -> View Controller -> 标识符 -> "ImagePickerViewController"

关于ios - Storyboard实例化 View Controller ,崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10910054/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com