简体   繁体   English

如何在情节提要场景中为UIButton编码

[英]How to code for a UIButton in a Storyboard scene

I don't know why but after searching on Google and here, no one seems to have this problem. 我不知道为什么,但是在Google和这里搜索之后,似乎没有人遇到这个问题。

I have added a new storyboard scene right next to my main scene, and wrote a code for a button which will trigger a partial curl transition to the new scene. 我在主场景旁边添加了一个新的情节提要场景,并为按钮编写了代码,该按钮将触发向新场景的部分卷曲过渡。

On my new scene, are a controls, here's my problem. 在我的新场景中,有一个控件,这是我的问题。 How can I code for them? 我该如何为他们编码? I cannot add them as IBOutlet or IBAction to my main scene's view controller which is pretty obvious. 我不能将它们作为IBOutlet或IBAction添加到我的主场景的视图控制器中,这很明显。 So what should I do? 所以我该怎么做? How can I add a new ViewController.h/m file for that new scene? 如何为该新场景添加新的ViewController.h / m文件?

To add this method to your ViewController.h/m, you will need to set the class of this view controller to "ViewController". 若要将此方法添加到ViewController.h / m,则需要将此视图控制器的类设置为“ ViewController”。 To do this, selected the view, and select "Show the identity inspector" in inspector, and then type the view controller class (ViewController) in Class field. 为此,选择视图,然后在检查器中选择“显示身份检查器”,然后在“类”字段中键入视图控制器类(ViewController)。

If you want this view controller to be in a different class, create that class without an XIB file and type that class name in Class field. 如果您希望此视图控制器位于其他类中,请创建没有XIB文件的类,然后在“类”字段中键入该类名称。

This will allow you to declare the IBAction/IBOutlet to that button in the class you specify. 这将允许您在指定的类中将IBAction / IBOutlet声明为该按钮。

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

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