iOS修改tableView删除侧滑的文字(通用办法iOS7,8,9都OK)
- (NSString*)tableView:(UITableView*)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath*)indexpath {
return@"编辑";
}
iOS7借用删除的样式经行一些操作
- (NSString*)tableView:(UITableView*)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath*)indexpath {
return@"编辑";
}
//iOS7中给定义的方式样式有: UITableViewCellEditingStyleNone,UITableViewCellEditingStyleDelete,UITableViewCellEditingStyleInsert
- (UITableViewCellEditingStyle)tableView:(UITableView*)tableView editingStyleForRowAtIndexPath:(NSIndexPath*)indexPath {
returnUITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView*)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath {
if(editingStyle ==UITableViewCellEditingStyleDelete) {
selectIndexPath= indexPath;
UIActionSheet*sheet = [[UIActionSheetalloc]initWithTitle:@"类型"delegate:selfcancelButtonTitle:@"取消"destructiveButtonTitle:nilotherButtonTitles:@"A类",@"B类",@"C类",@"D类",nil];
sheet.tag=501;
[sheetshowInView:[UIApplicationsharedApplication].keyWindow];
}
}
IOS8 之后使用的
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
returnYES;
}
//这个方法是IOS8之后的方法,为了方便侧滑经行操作,应为引入了UITableViewRowAction的类型有UITableViewRowActionStyleDefault =0,UITableViewRowActionStyleDestructive,UITableViewRowActionStyleNormal
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath { selectIndexPath = indexPath;
UITableViewRowAction *phoneBtn = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"编辑"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"类型"delegate:selfcancelButtonTitle:@"取消"destructiveButtonTitle:nilotherButtonTitles:@"A类",@"B类",@"C类",@"D类",nil];
sheet.tag =501;
[sheet showInView:[UIApplication sharedApplication].keyWindow];
}];
return@[phoneBtn];
}