是否有可能以编程方式显示红色删除按钮 UITableViewCell?

这里有许多类似的问题,但他们似乎没有一个特别询问这个问题,即,在代码中有任何方法可以强制红色删除按钮出现在行的右侧 UITableView?

我问的原因是我试图使用两个改变表格演示的行为 UISwipeGestureRecognizers 以便:

一个手指中的svile调用用户操作 /而不是显示红色删除按钮,它现在的行为/, 和

默认情况下,带有两个手指的滑动导致滑动的刷卡的行为,即它导致红色拆卸按钮。

我看了文件 SDK, 但我找不到任何方法来引起这个红色按钮的外观,这让我认为上述方案 UI 不可能在不从划痕中创建手动红色删除按钮而不尝试强制它来模拟内置行为的情况下实现。

任何帮助都非常有价值。
已邀请:

窦买办

赞同来自:

在手势选择器方法中 doubleFingerSwipe 安装一个变量并分配不是字符串 swiped 并重新启动表格 .



- /UITableViewCellEditingStyle/ tableView:/UITableView */tableView editingStyleForRowAtIndexPath:/NSIndexPath */indexPath
{
if/indexPath.row == yourVariable/ return UITableViewCellEditingStyleDelete;
else return UITableViewCellEditingStyleNone;
}


我认为它将适用于你的问题。

喜特乐

赞同来自:

- /UITableViewCell */tableView:/UITableView */tableView cellForRowAtIndexPath:/NSIndexPath */indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:@"cell %d",indexPath.row];

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if /cell == nil/
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
if/TableMethod==1/
{
UIButton *delete_btn=[UIButton buttonWithType:UIButtonTypeCustom];
[delete_btn setFrame:CGRectMake/10,15,25,25/];
delete_btn.tag=indexPath.row;
[delete_btn setImage:[UIImage imageNamed:@"remove_Icone.png"] forState:UIControlStateNormal];
[delete_btn addTarget:self action:@selector/delete_btn:/ forControlEvents:UIControlEventTouchUpInside];
[cell addSubview:delete_btn];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}

// Configure the cell.
return cell;
}


- /IBAction/delete_btn:/id/sender
{
UIButton *buttontag = /UIButton */sender;
//NSLog/@"%d",buttontag.tag/;
Delete_row = buttontag.tag;

UIAlertView *Alert = [[UIAlertView alloc]initWithTitle:@"Delete Reservation" message:@"Are you sure to want Delete Reservation ??" delegate:self cancelButtonTitle:@"Delete" otherButtonTitles:@"Cancel",nil];
Alert.tag=1;
[Alert show];
[Alert release];
}

-/void/alertView:/UIAlertView */alertView clickedButtonAtIndex:/NSInteger/buttonIndex
{
if/alertView.tag==1/
{
if/buttonIndex == 0/
{
// delete row
}
}
}

知食

赞同来自:

这不是您的问题的答案,而且是一个功能的提案 /我仍然不能留下评论,但我仍然想提供你的两美分/.

从观点 UI/UX 覆盖功能 default 或者 "expected"- 不太好主意。 用户对不同的应用程序和职能如何运作,以及在以这种方式不起作用的情况下,用户要么让人感到沮丧或混淆。 因此,功能分配 pull-to-refresh 几乎每个包含表格视图的附录。 什么是更合理的,因此它是用两个手指进行滑动,以定制功能。 然后您的申请不仅会符合传统建议。 UX /事实上,我想 Apple 可以拒绝其目前的表格申请,可能这就是为什么你这么难找到答案/, 但它需要更少的斗争/自定义代码。

遗憾的是,它不是直接回答你的问题,但我希望它会有所帮助。

喜特乐

赞同来自:

用电话


[self.tableView setEditing:YES animated:YES];


在 UITableViewController 你可以设置 tableView 编辑模式。 实际上,您可以将手势识别器添加到表示使用委托方法使此呼叫的单元格的单元格。

根据文件
http://developer.apple.com/lib ... .html
, 您可以以相同的方式确实设置相同的单元格。 此外,您将必须管理手势的标准签名。 我认为这些亚基将是你的盟友。

我希望它会有所帮助。

要回复问题请先登录注册