Xcode8无法将多个/单个uibutton连接到swift文件中的单个@IBAction [英] Xcode8 cannot connect multiple/single uibuttons to single @IBAction in swift file

查看:156
本文介绍了Xcode8无法将多个/单个uibutton连接到swift文件中的单个@IBAction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xcode 8 Beta.我无法从情节提要中拖动多个UIButton来连接到swift文件中的单个@IBAction.漏洞?感谢您的帮助.

I am using Xcode 8 beta. I cannot drag multiple UIButtons from storyboard to connect to a single @IBAction in swift file. Bug? Thanks for your help.

推荐答案

通过此替代方法,您可以添加现有操作,也可以将多个按钮连接到一个操作.

我认为Xcode8中存在错误.您可以通过将sender更改为_ sender

I think there is a bug in Xcode8. You can add multiple/Single button to a single action /function by changing sender to _ sender

例如:-普通按钮

   @IBAction func huu(sender: UIButton) {

   }

您不能为此操作添加多个按钮或单个按钮,而只需像这样简单地进行更改,然后就可以通过使用故事板中的拖动和连接来添加多个按钮.

You can't add multiple buttons or single button to this action you need to simply change like this and then you can add multiple buttons by using drag and connect from storyboard.

 @IBAction func huu(_ sender: UIButton) {

 }

连接IBOutlets之后,Xcode将显示如下警告:-

After connecting IBOutlets Xcode will show a warning like this :-

要删除此警告,只需从操作/功能中删除_标志即可.确保在连接IBOutlet之后删除_

To remove this warning simple delete _ sign from the action/function. Make sure that to delete _ after connecting your IBOutlets

希望这对您有帮助! :)

Hope that this will gonna help you! :)

这篇关于Xcode8无法将多个/单个uibutton连接到swift文件中的单个@IBAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆