简体   繁体   English

从已编程的按钮问题呈现UIViewController

[英]Presenting UIViewController from programmed button issues

I have a UIScrollView , with a button I created in my UIViewController that presents another view controller, but when I run it, it gives me an error that it cannot find storyboard name "AddVC" though my VC is named in the storyboard id " AddVC " I do have some pictures, so please take a look at it. 我有一个UIScrollView ,我在UIViewController中创建了一个按钮,该按钮提供了另一个视图控制器,但是当我运行它时,它给我一个错误,尽管我的VC在情节AddVC ID中命名为“ AddVC”,但它找不到情节提要名称“ AddVC”我有一些照片,所以请看一下。

here is the compiler: 这是编译器:

http://imgur.com/l0djhHA

here is the code: Button on top with action, with also part of a button on the bottom, ignore middle (sorry for large photo): 这是代码:顶部有动作的按钮,底部还有部分按钮,忽略中间(抱歉,大图):

http://imgur.com/a/Vs5MT And the storyboard: 和故事板:

http://imgur.com/a/A1COC

Please look at the images to help tell me what I am messing up, it is probably a simple fix. 请查看图片以帮助告诉我我在搞什么,这可能是一个简单的修复方法。

Thanks - Randy 谢谢-兰迪

It looks like you have give wrong name of your storyboard. 您似乎为故事板输入了错误的名称。 Replace the name with your actual storyboard name: 将名称替换为您的实际storyboard名称:

let vc = UIStoryboard(name:"Main", bundle: nil).instantiateViewController(withIdentifier:"AddVC")

Actually for storyboard name you have given storyboard ID. 实际上,对于情节提要名称,您已经给出了情节提要ID。 Try giving 尝试给予

let VC = UIStoryboard(name:<storyboard name>, bundle: nil).instantiateViewController(withIdentifier:"AddVC")

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM