iOS在UITableView上从左滑动,同时剩余滑动以删除
我使用简单的apple代码在我的tableview中实现了从右向左滑动删除,但我还想为另一个按钮添加我自己的从左向右滑动。基本上,我想要的功能与“滑动以删除”相同,但我将有一个自定义按钮,自定义滑动将从另一侧开始,而“滑动以删除”将保持功能 为了让它更直观,我尝试使用iOS在UITableView上从左滑动,同时剩余滑动以删除,ios,objective-c,uitableview,uipangesturerecognizer,Ios,Objective C,Uitableview,Uipangesturerecognizer,我使用简单的apple代码在我的tableview中实现了从右向左滑动删除,但我还想为另一个按钮添加我自己的从左向右滑动。基本上,我想要的功能与“滑动以删除”相同,但我将有一个自定义按钮,自定义滑动将从另一侧开始,而“滑动以删除”将保持功能 为了让它更直观,我尝试使用uipangestrerecognizer,这样用户可以在刷卡时看到单元格移动(就像要删除的刷卡一样)。但是,我不知道如何移动实际单元格,此外,还不知道如何在其下方添加按钮 我想我浏览了整个互联网,却找不到它。你有什么建议吗?这是一
uipangestrerecognizer
,这样用户可以在刷卡时看到单元格移动(就像要删除的刷卡一样)。但是,我不知道如何移动实际单元格,此外,还不知道如何在其下方添加按钮
我想我浏览了整个互联网,却找不到它。你有什么建议吗?这是一篇好文章,让你从概念层面开始 此外,还有几种开源解决方案:
这只是iOS8即将推出的功能(希望如此)的一个预告。这是一篇很好的文章,可以让您从概念层面开始 此外,还有几种开源解决方案:
这只是iOS8即将推出的功能(希望如此)的一个预告。我创建了一个新的库来实现可切换按钮,它支持各种转换和可扩展按钮,如iOS8邮件应用程序 此库与创建UITableViewCell及其在iOS 5、iOS 6、iOS 7和iOS 8上测试的所有不同方式兼容
我创建了一个新的库来实现可切换按钮,它支持各种转换和可扩展按钮,如iOS 8 mail app 此库与创建UITableViewCell及其在iOS 5、iOS 6、iOS 7和iOS 8上测试的所有不同方式兼容
加米的答案是正确的。我只是在objective-c中添加了这一点,以使初学者(以及那些拒绝学习Swift语法的人)更清楚:) 确保声明uitableviewdelegate并使用以下方法:
-(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *button = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Button 1" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath)
{
NSLog(@"Action to perform with Button 1");
}];
button.backgroundColor = [UIColor greenColor]; //arbitrary color
UITableViewRowAction *button2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Button 2" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath)
{
NSLog(@"Action to perform with Button2!");
}];
button2.backgroundColor = [UIColor blueColor]; //arbitrary color
return @[button, button2]; //array with all the buttons you want. 1,2,3, etc...
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
// you need to implement this method too or nothing will work:
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES; //tableview must be editable or nothing will work...
}
加米的答案是正确的。我只是在objective-c中添加了这一点,以使初学者(以及那些拒绝学习Swift语法的人)更清楚:) 确保声明uitableviewdelegate并使用以下方法:
-(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *button = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Button 1" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath)
{
NSLog(@"Action to perform with Button 1");
}];
button.backgroundColor = [UIColor greenColor]; //arbitrary color
UITableViewRowAction *button2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Button 2" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath)
{
NSLog(@"Action to perform with Button2!");
}];
button2.backgroundColor = [UIColor blueColor]; //arbitrary color
return @[button, button2]; //array with all the buttons you want. 1,2,3, etc...
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
// you need to implement this method too or nothing will work:
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES; //tableview must be editable or nothing will work...
}
这看起来很棒!感谢您的时间和所有这些有用的链接。我可能会坚持你给我的一个开源解决方案。这看起来很棒!感谢您的时间和所有这些有用的链接。我可能会坚持你给我的一个开源解决方案。