accessoriesView を適切な 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))
}
}
デバッグでチェックしたところ、「折りたたみ」画像を設定したり、「編集」画像を設定したりすることもありましたが、その後は常にセルに「編集」画像が表示されます。
したがって、最初にaccessoryViewを設定すると、その後は変更できません(実際にはビューポインターを変更できますが、その後画面に変更は表示されません)