我试图将 UILabel 转换为字符串,但总是失败。我还能怎么投呢? friendname
是一个 UILabel,friendusername
是一个字符串。
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier == "friendsSongs"){
let nextViewOBJ = segue.destinationViewController as! FriendsMusic
nextViewOBJ.friendusername = friendname as! String
}
}
最佳答案
使用 text
UILabel 上的属性:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier == "friendsSongs"){
let nextViewOBJ = segue.destinationViewController as! FriendsMusic
nextViewOBJ.friendusername = friendname.text
}
}
您不能将 UILabel 转换为字符串 - 但您可以找到 UILabel 的文本是什么。这就是您想在这里做的。
关于ios - 如何将 UILabel 转换为字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33634766/