我有一个TableView,每个单元的附件设置为“披露指示器”,它正常工作。
然后,我决定在使用外部数据更新每个单元格时添加一个活动指示器。为此,我设置了:
cell.accessoryView = UIActivityIndicatorView(activityIndicatorStyle: .Gray)
当我完成从外部来源加载数据时,我丢失了“披露指示符”(单元格右侧的箭头)。我应该将“cell.accessoryView”恢复为什么?
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let item = items[indexPath.row]
var cell = self.tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! UITableViewCell
// SET ACTIVITY INDICATOR HERE
if cell.accessoryView == nil {
let indicator = UIActivityIndicatorView(activityIndicatorStyle: .Gray)
cell.accessoryView = indicator
}
let indicator = cell.accessoryView as! UIActivityIndicatorView
// ... some code here ...
switch (item.state) {
case .New:
indicator.startAnimating()
self.fetchExternalData(item, indexPath:indexPath)
case .Downloaded:
indicator.stopAnimating()
// I'D LIKE TO RESTORE THE DISCLOSURE INDICATOR HERE
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
// cell.accessoryView = ???
}
return cell
}
答案 0 :(得分:2)
糟糕,我只是尝试设置" cell.accessoryView = nil"并且它有效..在发布之前我应该想到这一点: - (
答案 1 :(得分:0)
当然您需要设置
cell.accessoryType = UITableViewCellAccessoryNone;
更改附件之前