I have a TableView that pulls in a custom cell of the custom class GroupTableView. I'm able to scroll through without any issue when not in edit mode (all the data remains in the right cells etc.). However, when I go into edit mode, the delete button disappears as I scroll through the table.
Here's my code for the tableview:
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return groups.count
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell: GroupTableView = tableView.dequeueReusableCellWithIdentifier(groupCellID) as GroupTableView
if (cell == nil) {
cell = GroupTableView(style: UITableViewCellStyle.Default, reuseIdentifier: groupCellID)
}
cell.groupName.text = groups[indexPath.row].groupName
cell.groupOwner.text = "OwnerID: \(groups[indexPath.row].ownerID)"
cell.numPosts.text = groups[indexPath.row].numPosts
return cell;
}
func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
if (groupTableView.editing == true)
{
self.performSegueWithIdentifier("segueToGroupDetail",sender:self)
}
else
{
self.performSegueWithIdentifier("segueToLinkView",sender:self)
}
}
Here's my code to enable edit mode:
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.leftBarButtonItem = self.editButtonItem()
}
override func setEditing(editing: Bool, animated: Bool)
{
super.setEditing(editing,animated:animated)
groupTableView.setEditing(editing,animated:animated)
}
This is written in swift, but hopefully conceptually similar to how it would be done in objective-c.