简体   繁体   English

无法控制拖动到ViewController.swift

[英]Cannot Control-Drag into ViewController.swift

I am trying to control-drag objects in the storyboard into the ViewController.swift, but nothing is working. 我试图控制将情节提要中的对象拖放到ViewController.swift中,但是没有任何效果。 I have tried sliders, buttons, switches, pickers, everything. 我尝试过滑块,按钮,开关,选择器等所有功能。 I need to finish this app quickly, so please help! 我需要快速完成此应用,因此请帮忙!

You probably didn't set your view controller class in your Utility inspector. 您可能没有在工具检查器中设置视图控制器类。

When you are on your Storyboard, select your view controller, open the Utility inspector (right panel) and set the related class (which is ViewController in your case). 在情节提要中时,选择视图控制器,打开“工具”检查器(右面板)并设置相关的类(在您的情况下为ViewController )。 This way, you'll be able to ctrl + drag 这样,您就可以ctrl + drag

在此处输入图片说明

When you create your new file to inherit UIViewController, it should be a CocoaTouch Class and not a swift class. 当您创建新文件以继承UIViewController时,它应该是CocoaTouch类而不是swift类。 then you can drag from your Main.storyboard to the new View Controller. 然后您可以从Main.storyboard拖动到新的View Controller。 在此处输入图片说明

I had faced the same problem. 我曾经遇到过同样的问题。 This is what I noticed if you are trying to drag drop into the storyboard with ctrl button pressed the drag drop does not work. 这就是我注意到的,如果您尝试使用ctrl按钮将拖放拖放到情节提要中,则拖放不起作用。 Just click drag and drop from the touchpad. 只需在触摸板上单击拖放即可。 I guess this should help. 我想这应该有所帮助。

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

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