Ios 将UIButton视为CellForRowatineXpath中的UILabel

Ios 将UIButton视为CellForRowatineXpath中的UILabel,ios,swift,uitableview,parse-platform,uibutton,Ios,Swift,Uitableview,Parse Platform,Uibutton,如何将UIButton视为CellForRowatineXpath中的UILabel,我想在CellForRowatineXpath中将其称为UILabel 我得到这个错误: 无法将字符串类型的值分配给UIButton类型 我正在使用PFQueryTableViewController cell.cityButton = object?.objectForKey("City") as? String cell.locationLabel.text = object?.objectForKey

如何将UIButton视为CellForRowatineXpath中的UILabel,我想在CellForRowatineXpath中将其称为UILabel

我得到这个错误:

无法将字符串类型的值分配给UIButton类型

我正在使用PFQueryTableViewController

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

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

您试图将
城市按钮
设置为(可选)
字符串
,这显然不起作用。相反,您希望将按钮的标题设置为该字符串。试试这个:

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

您试图将
城市按钮
设置为(可选)
字符串
,这显然不起作用。相反,您希望将按钮的标题设置为该字符串。试试这个:

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

尝试使用此:
cell.cityButton.setTitle(object?.objectForKey(“City”)作为?字符串用于状态:.Normal)
尝试使用此:
cell.cityButton.setTitle(object?.objectForKey(“City”)作为?字符串用于状态:.Normal)