【发布时间】:2018-07-18 07:50:59
【问题描述】:
我想在 UIlabel 上显示价值。当我按下 UIbutton 来增加或减少标签上的值时。这是我的代码,当我运行我的项目时,我的 uilabel 没有任何价值。
@IBAction func btnIncreaseAction(_ sender: Any) {
var count = 0
count = (count + 1)
if let cell = (sender as? UIButton)?.superview?.superview?.superview as? ShoppingCell
{
//cell.lblForOnty.text = "\(cell.lblForOnty.text ?? 0 + 1)"
cell.lblForOnty.text = String(count)
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CellRID") as! ShoppingCell
var someValue: Int = 0 {
didSet {
cell.lblForOnty.text = "\(count)"
}
}
return cell
}
}
【问题讨论】:
-
你能在单元格中显示按钮层次结构吗
-
只有你的单元格中的按钮增加了吗?
标签: ios swift uitableview uibutton