there are 5 section in my tableview 1)1 and 2 are not editable while 3,4,and 5 are editable in section 1 am using checkbox,2 radio box , 3 insert cell , 4 delete cell ,5 move cell
so for last 3 i want my tableview will be come editable and sign of + and - will be shown in starting of cell.
and not fo开发者_高级运维r forst 2 section. i tried - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
but this is not working. any help please?
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
NSInteger section = [indexPath section];
if (section ==0)
return NO;
if (section ==1)
return NO;
if (section ==2)
return YES;
if (section ==3)
return YES;
if (section ==4)
return YES;
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
[self.tableView setEditing:editing animated:animated];
[tableView reloadData];
}
You're on the right track with tableView:canEditRowAtIndexPath:
. You'll also want to implement tableView:editingStyleForRowAtIndexPath:.
Also, are you calling setEditing:animated on your UITableView to put the table into editing mode? I assume you are, but it never hurts to double-check.
精彩评论