你好,我有一个如下所示的 profilelbl 变量,它是一个 uibutton。我希望按钮的文本成为我的数据库中的输入(解析)。但我想不通。我尝试了很多东西,但仍然出现错误:
@IBOutlet weak var profileLbl: UIButton!
var notification = PFObject(className: "notifications")
notification["actionReceiverName"] = profilelbl.text /*not working*/
/* also tried
notification["actionReceiverName"] = sender.profilelbl.text
notification["actionReceiverName"] = profilelbl.title */
最佳答案
你可以轻松做到这一点
if let button = profilelbl as? UIButton {
if let title = button.titleForState(.Normal) {
println(title)
notification["actionReceiverName"] = title
}
}
关于ios - 使用 UIButton 文本作为文本输入 - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30936933/