我想在UITableViewCell
中显示信息。我希望能够在单元格上向左滑动,而不是显示deleteCellButton我想看到一段内容。
如何覆盖此方法才能做到这一点。
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
}
您的帮助将不胜感激
答案 0 :(得分:1)
您可以使用以下委托方法
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"Some Content";
}
//正常委托方法
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Determine if it's in editing mode
if (self.tableView.editing)
{
return UITableViewCellEditingStyleDelete;
}
return UITableViewCellEditingStyleNone;
}
希望它可以帮助你......!
答案 1 :(得分:0)
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete)
{
//add code here for when you hit delete
NSLog(@"selected row is : %d",indexPath.row);
NSString *frndName = [[sections valueForKey:[[[sections allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];
NSString *remove = [NSString stringWithFormat:@"Are you sure want to remove '%@' from your friends?",frndName];
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"" message:remove delegate:self cancelButtonTitle:@"Remove" otherButtonTitles:@"Cancel", nil];
av.title = frndName;
[av show];
}
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"editingStyleForRowAtIndexPath");
return UITableViewCellEditingStyleDelete;
}
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return @"Remove";
}
答案 2 :(得分:0)
如果您想要显示更多操作,可以实施tableView:editActionsForRowAtIndexPath:
UITableViewDelegate
方法。
看一下UITableViewRowAction
课程,看看有什么可能:
here