无法将插座从故事板拖到 XCode 中的助理编辑器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11285993/
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
Can't drag outlets from Storyboard to Assistant editor in XCode
提问by econclicks
I used to be able to do this in XCode, and now suddenly I can't in a new project I've opened that was sent over by a friend.
我以前可以在 XCode 中执行此操作,但现在突然无法在我打开的一个朋友发送的新项目中执行此操作。
Is there a particular setting I have to change to start this again?
是否需要更改特定设置才能再次启动?
I.e. there is a textbox I want to link via Code, and now I just can't. :(
即有一个文本框我想通过代码链接,现在我不能。:(
Need help guys!
需要帮助的家伙!
回答by Omar Abdelhafith
You most likely have an assistant editor window opened to a wrong class, you will need to check on your currently selected view controller and make sure that its the same that is opened in the assistant editor
您很可能在一个错误的类中打开了一个辅助编辑器窗口,您需要检查当前选择的视图控制器并确保它与在辅助编辑器中打开的相同
Or in assistant editor, select automatic (check screenshot)
或在助理编辑器中,选择自动(检查截图)
回答by Hennish
I was having the same issue and looked all over and couldn't find a good fix to the problem. What was happening when my Controllers were first generated they had the generic names FirstController. When I switched the names I didn't switch the value in the Custom Class area. To fix:
我遇到了同样的问题,四处查看,找不到解决问题的好方法。我的控制器第一次生成时发生了什么,它们具有通用名称 FirstController。当我切换名称时,我没有切换自定义类区域中的值。修理:
- Select View.xib
- Select File's Owner under placeholders. This should be on the left side of the screen with a yellow cube next to it.
- Select the third option on the utilities menu (Identity)
- Change the Custom Class class to the correct Controller name.
- 选择视图.xib
- 选择占位符下的文件所有者。这应该在屏幕的左侧,旁边有一个黄色的立方体。
- 选择实用程序菜单上的第三个选项(身份)
- 将自定义类类更改为正确的控制器名称。
I know this wasn't the specific question's issue but I clicked on this question a few times so thought if someone had the same issue it might be helpful.
我知道这不是具体问题的问题,但我点击了几次这个问题,所以想如果有人有同样的问题可能会有所帮助。
回答by Ronen Rabinovici
The solution for me was simply to press Ctrl while dragging...
对我来说,解决方案只是在拖动时按下 Ctrl 键...
回答by Lazar Kukolj
With the latest version of Xcode when I open up the Storyboard and .h file, I remove the last space below the @end
tag on the bottom of the (fresh) .h file. Which for some reason wouldn't let me place the outlet after doing so, thanks Apple!
当我打开 Storyboard 和 .h 文件时,使用最新版本的 Xcode,我删除@end
了(新鲜).h 文件底部标签下方的最后一个空格。出于某种原因,这样做后我不允许我放置插座,谢谢Apple!
So to fix my problem i have to have that extra space below the @end
tag in the .h file.
所以为了解决我的问题,我必须@end
在 .h 文件中的标签下方留出额外的空间。
This is what fixed my problem and I know it doesn't answer this specific question but hopefully, it helps someone.
这就是解决我的问题的原因,我知道它没有回答这个特定问题,但希望它可以帮助某人。
回答by Dania Delbani
I had the same problem, In my case there was a mismatch between my class name at the identity inspector and that one at source code.
我遇到了同样的问题,就我而言,身份检查器中的类名与源代码中的类名不匹配。
回答by xaphod
Had this issue too.
XCode 9: make sure in the Storyboard -> Identity Inspector -> "Inherit from Module from Target"
is checked (or fill out the module name manually)
也有这个问题。XCode 9:确保在 Storyboard -> Identity Inspector ->"Inherit from Module from Target"
被选中(或手动填写模块名称)
EDIT: Turns out checking that box doesn't help -- if you delete the class of the UIViewController, then type it in manually and hit Enter, in XCode 9 if there's a problem the checkbox "Inherit Module from Target"
will notauto check itself. After trial and error it turned out in the class (Swift 4), there was a #if IDENTIFIER .... #endif
which was perfectly valid, but screwed up Storyboard connections some how. After removing it, typing the class name in the storyboard auto-checked the box, and now connections work. Yay another XCode 9 bug.
编辑:结果检查那个框没有帮助——如果你删除了 UIViewController 的类,然后手动输入它并按 Enter,在 XCode 9 中,如果出现问题,复选框"Inherit Module from Target"
将不会自动检查自身。经过反复试验,结果在课堂上(Swift 4),有一个#if IDENTIFIER .... #endif
完全有效的,但在某些方面搞砸了故事板连接。删除它后,在故事板中输入类名会自动选中该框,现在连接工作。是的,另一个 XCode 9 错误。