Xcode 6 无法拖动 ImageView 来创建插座集合
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26068225/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 6 cannot drag ImageView to create outlet collection
提问by Reece Kenney
I am using Xcode 6 and so far I have had nothing but problems. My most recent problem however really has baffled me. I am creating a Tic Tac Toe game and I am using 9 image view objects. I am trying to ctrl drag across from the objects to my swift file in assistant editor but when I try to drag, nothing happens. Usually that blue line would appear right where your outlet would be created when you let go of the mouse but literally nothing is happening no matter where in the file I drag it to.
我正在使用 Xcode 6,到目前为止我只有问题。然而,我最近的问题真的让我感到困惑。我正在创建一个井字游戏,我正在使用 9 个图像视图对象。我试图在助理编辑器中将对象从对象拖到我的 swift 文件中,但是当我尝试拖动时,没有任何反应。通常,当您松开鼠标时,这条蓝线会出现在创建插座的位置,但实际上无论我将它拖到文件中的哪个位置,都没有发生任何事情。
Any ideas? Thanks
有任何想法吗?谢谢
回答by Imanou Petit
Try this step by step.
逐步尝试此操作。
0/ Check in your Storyboard's Identity Inspector that the UIViewController
/ UITableViewCell
/ etc that contains your UIImageView
s has the correct class name.
0 /检查你的故事板的身份检查了UIViewController
/UITableViewCell
包含你的/ etc UIImageView
S有正确的类名。
1/ Add the following code in your class:
1/ 在你的类中添加以下代码:
@IBOutlet var imageViewCollection: [AnyObject]!
2/ From your class, drag your imageViewCollection
outlet to your UIImageView
s. Or, from Connections Inspector, drag your imageViewCollection
outlet to your UIImageView
s (see image below).
2/从你的班级,把你的imageViewCollection
插座拖到你的UIImageView
s。或者,从 Connections Inspector 中,将您的imageViewCollection
插座拖到您的UIImageView
s(见下图)。
3/ In your class, replace AnyObject
with UIImageView
so that your imageViewCollection
declaration looks like the following:
3/ 在您的班级中,替换AnyObject
为UIImageView
使您的imageViewCollection
声明如下所示:
@IBOutlet var imageViewCollection: [UIImageView]!