【发布时间】:2015-04-24 14:05:57
【问题描述】:
我有一个自定义 UITableViewCell 类,我希望它在进入编辑模式时显示一个披露指示器。
这是我的方法:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: CustomCellClass = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! CustomCellClass
cell.counterTitle.text = "Cell Title"
if self.tableView.editing {
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
}
return cell
}
我想我在这里找到了答案,但我很难将其翻译成 swift:link
我需要第二个自定义单元类来解决这个问题吗?
谢谢
【问题讨论】:
-
你从上面的代码中得到了什么?有什么错误吗?
-
没有错误,但披露指示符也没有出现。
-
尝试在开始编辑 tableView 时调用 reloadData - 如果在 tableView 进入编辑模式时自动触发委托方法,我不记得了。除此之外,为了进一步调试,我会注销并确保您实际上处于编辑模式。
-
那一个有效,但没有动画:
self.tableView.setEditing(true, animated: true) self.tableView.reloadData()当您在闹钟列表视图中按编辑时,它一点也不流畅,就像在股票 iOS 时钟应用程序中一样。我还想过创建第二个自定义单元类。然后我只需要告诉 UITableView 用第二个标识符重新加载数据。如何做到这一点?
标签: ios objective-c uitableview swift