【问题标题】:UIButtons in UITableViewCell do not show textLabel changes until cells scroll off screenUITableViewCell 中的 UIButtons 不显示 textLabel 更改,直到单元格滚出屏幕
【发布时间】:2015-06-22 21:58:27
【问题描述】:

我有一个带有日历的 UIViewController,它下面是一个带有 UITableViewCell 的 UITableView,它有一系列 UIButton,我根据检索到的数据更改按钮文本。选择日期后,我更新 NSArray 并调用 [self.tableView reloadData]。第一行按应有的方式填充,UIButton 标题显示正确的数据。其余行显示情节提要中 UIButtons 的默认值。如果我从屏幕上滚动一个单元格并让它回来,它会显示正确的数据(即更新 UIButtons 的标题)。我不确定为什么会这样。我尝试添加 [cell setNeedsLayout] 在返回单元格之前,但它没有帮助。

【问题讨论】:

  • 你是直接修改testLabels吗?如果你这样做,UIButtons 有时会有不确定的行为。尝试使用 UIButton 方法更改 textLabel 的属性,例如 setTitle: forState:
  • 好建议,但没有解决问题。
  • @Aderis 实际上您的建议确实有效。我在如何实现它时犯了一个错误。谢谢。

标签: ios iphone uitableview uiviewcontroller uibutton


【解决方案1】:

你是直接修改 testLabels 吗?如果你这样做,UIButtons 有时会有不确定的行为。尝试使用 UIButton 方法更改 textLabel 的属性,例如 setTitle: forState:

【讨论】:

    猜你喜欢
    • 2017-03-10
    • 1970-01-01
    • 2013-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-29
    相关资源
    最近更新 更多