Ios UIAPgestureRecognition with UILabel获取函数中的标签文本
我有一个电话号码和电子邮件的标签。如果单击电子邮件标签,邮件应用程序将打开,其中包含标签内定义的邮件 这就是我的职责:Ios UIAPgestureRecognition with UILabel获取函数中的标签文本,ios,swift,uilabel,uitapgesturerecognizer,clickable,Ios,Swift,Uilabel,Uitapgesturerecognizer,Clickable,我有一个电话号码和电子邮件的标签。如果单击电子邮件标签,邮件应用程序将打开,其中包含标签内定义的邮件 这就是我的职责: func tapMailFunction(sender:UITapGestureRecognizer) { print("tapMail working") } 在cellForRowAt内,我设置了以下内容: cell.Mail.addGestureRecognizer(tapMail) 这就是我的UITapGestureRecognitor的外观: let ta
func tapMailFunction(sender:UITapGestureRecognizer) {
print("tapMail working")
}
在cellForRowAt内,我设置了以下内容:
cell.Mail.addGestureRecognizer(tapMail)
这就是我的UITapGestureRecognitor的外观:
let tapMail = UITapGestureRecognizer(target: self, action: Selector(TestViewController.tapMailFunction))
如何在我的函数中获取cell.Mail.text 您可以使用识别器对象获取相关视图。大概是这样的:
func tapMailFunction(sender:UITapGestureRecognizer) {
if let label = sender.view as? UILabel {
let text = label.text
}
}