iosiphoneuitablevieweditmode

UITableView Edit mode


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?


Solution

  • as Anish pointed to using

    [tableView setEditing: YES animated: YES]; 
    

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