是否可以在同一个 ViewController 中将两个按钮 link 用于两个不同的 ibactions?
Is it possible to link two buttons to two different ibactions in the same ViewController?
我在做一个项目,我有两个按钮,一个用于发送邮件,第二个是图像选择器。
我可以 link 我的 @IBAction sendMail
我的第一个按钮,但我不能用我的 @IBAction imagePicker
.
当我从情节提要到界面文件执行 "drag and drop" 时,我的 ViewController 没有任何反应。蓝色条在这里,但没有 window 弹出来创建 link..
如果能提供一点帮助,我们将不胜感激。
这是代码:
internal class ViewController : UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
override internal func viewDidLoad()
@IBAction internal func
sendEmail(_ sender: any)
@IBAction internal func
imagePicker(_ sender: UIButton)
}
您可能已经解决了,但问题的根源可能是您查看的是文件界面而不是文件。
在你的故事板上,触摸你 ViewController 的黄色圆圈。
然后点击 xCode 右上角有两个圆环的按钮:
现在从自动更改为手动:
最后,找到名称中没有(接口)的 ViewController 并在那里连接 de action。
如果你做对了,现在你可以在你的动作左侧看到一个白色圆圈,如下所示:
我在做一个项目,我有两个按钮,一个用于发送邮件,第二个是图像选择器。
我可以 link 我的 @IBAction sendMail
我的第一个按钮,但我不能用我的 @IBAction imagePicker
.
当我从情节提要到界面文件执行 "drag and drop" 时,我的 ViewController 没有任何反应。蓝色条在这里,但没有 window 弹出来创建 link..
如果能提供一点帮助,我们将不胜感激。 这是代码:
internal class ViewController : UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
override internal func viewDidLoad()
@IBAction internal func
sendEmail(_ sender: any)
@IBAction internal func
imagePicker(_ sender: UIButton)
}
您可能已经解决了,但问题的根源可能是您查看的是文件界面而不是文件。
在你的故事板上,触摸你 ViewController 的黄色圆圈。
然后点击 xCode 右上角有两个圆环的按钮:
现在从自动更改为手动:
最后,找到名称中没有(接口)的 ViewController 并在那里连接 de action。
如果你做对了,现在你可以在你的动作左侧看到一个白色圆圈,如下所示: