简体   繁体   English

滑动表格单元格以获得两个选项

[英]Swipe a table cell to get two options

I'm stuck on this bit because there is some information scattered all over, but never a solid explanation.我被困在这一点上,因为到处都有一些信息,但从来没有一个可靠的解释。

I've got a table view, filled with cells and sections.我有一个表格视图,里面充满了单元格和部分。 I'd like to see when I swipe on a cell (to the right), I get two buttons: 'Accept' and 'Reject'.我想看看当我在一个单元格上滑动时(向右),我得到两个按钮:“接受”和“拒绝”。

I've gotten as far as seeing the delete button.我已经看到了删除按钮。 This only occurs anything but the first cell on each section (here, the program just detects didSelectRowAtIndexPath ), and I've got no clue on how getting a second button in the cell, let alone editing those buttons.这只发生在每个部分的第一个单元格之外(这里,程序只检测didSelectRowAtIndexPath ),我不知道如何在单元格中获得第二个按钮,更不用说编辑这些按钮了。

Anyone having any idea?任何人有任何想法?

You'll need to subclass UITableViewCell and add a GestureRecognizer in order to get this effect.您需要继承 UITableViewCell 并添加 GestureRecognizer 才能获得此效果。 The standard table editing functionality won't quite cut it here.标准的表格编辑功能在这里不会完全适用。 The open source ELCImagePickerController does something similar in its ELCAssetCell.m that ought to get you moving in the right direction:开源ELCImagePickerController在其 ELCAssetCell.m 中做了类似的事情,应该会让你朝着正确的方向前进:

[elcAsset addGestureRecognizer:[[[UITapGestureRecognizer alloc] initWithTarget:elcAsset action:@selector(toggleSelection)] autorelease]];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM