UITableView Edit mode

user739509 picture user739509 · May 14, 2011 · Viewed 57.1k times · Source

I have UITableView and I am trying to load it by default in edit mode. The problem is when I this line table.editing=TRUE; my rows disappear, I implemented this methods:

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 
{
// Return NO if you do not want the specified item to be editable.
return YES;
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 
{
return UITableViewCellEditingStyleDelete;
}


 - (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath 
 {
 return NO;
 }

but with no luck. What should I do?

Answer

Ahmad Kayyali picture Ahmad Kayyali · May 14, 2011

as Anish pointed to using

[tableView setEditing: YES animated: YES]; 

But you need to have it in viewWillAppear view event to make it work.