简体   繁体   English

链接我的计时器按钮(Xcode)时遇到问题

[英]Having trouble linking my timer buttons (Xcode)

UPDATE: Thank you to everyone that offered a solution. 更新:感谢所有提供解决方案的人。 And it appears XCode was just being a bit buggy because I came back to my project and it's working fine now. 而且看起来XCode只是有点儿马车,因为我回到我的项目并且现在工作正常。 Again thank you! 再次谢谢你!

first thank you to anyone who offers some help. 首先感谢任何提供帮助的人。

I am attempting to link my buttons and nothing happens when I try to drag them to their connection. 我试图链接我的按钮,当我尝试将它们拖动到他们的连接时没有任何反应。

As you can see the selection does not highlight to allow for the connection. 如您所见,选择不会突出显示以允许连接。 I was able to connect the Date Picker but have had no luck with the start, stop, or pause button. 我能够连接日期选择器,但没有运气启动,停止或暂停按钮。 I am learning from the Instructable tutorial. 我正在从Instructable教程中学习。

截图

Any help would be awesome 任何帮助都是极好的

If you cannot link to an item in your storyboard from an outlet and the item on the storyboard does not highlight, the usual issue is that you have not set the correct class/object type. 如果您无法从插座链接到故事板中的项目且故事板上的项目未突出显示,则通常的问题是您尚未设置正确的类/对象类型。 For instance, if you have specified a sub-class of UIButton type in your IBOutlet declaration but have a plain UIButton on the storyboard, or a totally different class than UIButton in your your IBOutlet declaration, you might not be able to link the items. 举例来说,如果你指定一个子类UIButton输入您的IBOutlet声明,但有一个简单UIButton的故事板,或一个完全不同的类比UIButton在您的IBOutlet中声明,你可能无法链接的项目。

I noticed that sometimes even if you have the correct class, this BUG can occur. 我注意到有时即使你有正确的类,这个BUG也会发生。 (IF you have everything else set straight as from the comments and other answers here) (如果您还有其他所有内容,请点击此处的评论和其他答案)

Instead of cleaning projects and restarting Xcode as others suggest (which maybe is needed sometimes) 而不像其他人建议的那样清理项目并重新启动Xcode(有时可能需要)

Another solution: 另一种方案:

1: Create a property IBOutlet manually typed where you want to connect it. 1:创建属性IBOutlet手动键入要连接的位置。

2: Once created, drag the property IBOutlet from the code to the element in the storyBoard instead of the other way around. 2:创建后,将属性IBOutlet 从代码拖到storyBoard中的元素,而不是相反。

You will notice things will connect without problems and everything will start working again. 你会发现事情会毫无问题地连接起来,一切都会重新开始。

在此输入图像描述

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

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