【问题标题】:Treat UIButton as UILabel in cellForRowAtIndexPath在 cellForRowAtIndexPath 中将 UIButton 视为 UILabel
【发布时间】:2015-12-06 17:52:13
【问题描述】:

如何在 cellForRowAtIndexPath 中将 UIButton 视为 UILabel,我想在 cellForRowAtIndexPath 中将其称为 UILabel。

我得到这个错误:

无法将 String 类型的值赋给 UIButton 类型

我正在使用 PFQueryTableViewController。

 cell.cityButton = object?.objectForKey("City") as? String

cell.locationLabel.text = object?.objectForKey("eventLocation") as? String

【问题讨论】:

    标签: ios swift uitableview parse-platform uibutton


    【解决方案1】:

    您正在尝试将cityButton 设置为等于(可选)String,这显然不起作用。相反,您希望将按钮的标题设置为该字符串。试试这个:

    cell.cityButton.setTitle(object?.objectForKey("City") as? String forState: .Normal)
    

    【讨论】:

      【解决方案2】:

      试试这个:cell.cityButton.setTitle(object?.objectForKey("City") as? String forState: .Normal)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多