我需要将附件视图更改为正确的 UIImageView
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView .dequeueReusableCellWithIdentifier("ActivitySectionCell") as! ActivitySectionCell
var imageNameOfAccessory = expandedSections.containsIndex(indexPath.section) ? "collapse" : "edit"
cell.accessoryView = UIImageView(image: UIImage(named: imageNameOfAccessory))
return cell
}
func tableView(tableViewMethod: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableViewMethod.deselectRowAtIndexPath(indexPath, animated: true)
var cell = tableView(self.tableViewMain, cellForRowAtIndexPath: indexPath) as! ActivitySectionCell
if currentlyExpanded {
var imageNameOfAccessory = !currentlyExpanded ? "collapse" : "edit"
cell.accessoryView = UIImageView(image: UIImage(named: imageNameOfAccessory))
}
else {
var imageNameOfAccessory = !currentlyExpanded ? "collapse" : "edit"
cell.accessoryView = UIImageView(image: UIImage(named: imageNameOfAccessory))
}
}
我检查了调试,有时我设置了“折叠”图像,有时设置了“编辑”图像,但之后我总是在单元格中看到“编辑”图像。
所以当我一开始设置附件视图时,之后就无法更改(实际上我可以更改视图指针,但之后在屏幕上我看不到任何更改)