简体   繁体   English

Xcode不会让我拖放按钮

[英]Xcode wont let me drag and drop buttons

I have been working with xcode for about 3 days. 我已经使用xcode大约3天了。 Everything worked just fine up until today. 直到今天,一切都正常。 I was dragging buttons and labels to where my code is located just fine as shown in the first screenshot but for some reason, it wont let me drag and drop items from the second view control . 我将按钮和标签拖到我的代码所在的位置,如第一个屏幕截图所示,但由于某种原因,它不允许我从第二个视图控件中拖放项目。 Im sure its an easy fix but i cant seem to find a soulution on my own. 我肯定这是一个简单的解决方法,但我似乎自己找不到解决方法。 I have researched it and people have had the same issue but that was due to their code. 我已经研究过了,人们也遇到了同样的问题,但这是由于他们的代码。 Mine is fresh since I created a new project and it does not like my second viewcontrol. 自从我创建了一个新项目以来,我的工作就很新鲜,它不喜欢我的第二个viewcontrol。

第二屏不让我拖放

第一屏工作正常

You cant use one view controller for multiple views. 您不能将一个视图控制器用于多个视图。 For all views you have, you need your own custom controller class. 对于您拥有的所有视图,您需要自己的自定义控制器类。 That means, that you need to create a new view controller class(cmd + N), select Cocoa Touch class, name it, and in the identity inspector of your second view(in the Storyboard), select your new view controller class. 这意味着,您需要创建一个新的视图控制器类(cmd + N),选择Cocoa Touch类,为其命名,然后在第二个视图的身份检查器中(在Storyboard中)选择新的视图控制器类。 Then you can drag and drop labels, buttons, etc, when on the right size of the assistant editor, your second view controller class is opened. 然后,您可以拖放标签,按钮等,当在助手编辑器的大小合适时,将打开第二个视图控制器类。

Create an another class ExampleViewController and call it in identity inspector. 创建另一个类ExampleViewController,然后在身份检查器中调用它。 More about identity inspector: apple lesson 有关身份检查器的更多信息: 苹果课程

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

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