简体   繁体   English

无法将自定义类分配给Xcode 7中的视图

[英]Cannot assign a custom class to a view in Xcode 7

In Xcode 7 using Swift, I am trying to make a Snapchat-like camera. 在使用Swift的Xcode 7中,我正在尝试制作类似Snapchat的相机。 However, Xcode will not let me control-click and drag (or right-click and drag) a view from my CameraView.xib file to my CameraView.swift file. 但是,Xcode不允许我按住Control键单击并拖动(或右键单击并拖动)视图从CameraView.xib文件到CameraView.swift文件。 The view I am trying to control-click and drag is a subview of another view. 我试图控制单击并拖动的视图是另一个视图的子视图。 I have read other similar questions, and the answers say to move the view outside of the other view, change the custom class, make the connection to the .swift file, then put it back as a subview. 我读过其他类似的问题,答案说是将视图移到其他视图之外,更改自定义类,建立与.swift文件的连接,然后将其放回子视图。 However, Xcode will not allow me to assign a custom class to the view. 但是,Xcode不允许我向视图分配自定义类。 Any suggestions on how to fix this issue? 有关如何解决此问题的任何建议?

You have to go to your xib, select the root view in the xib, then choose identity inspector on the right. 您必须转到xib,在xib中选择根视图,然后在右侧选择“身份检查器”。

在此处输入图片说明

In there you have to set the custom class to CameraView 在这里,您必须将自定义类设置为CameraView

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

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