UITableViewCell添加长按手势问题

本文介绍了如何在UITableViewCell中添加长按手势,以便实现类似删除收藏或浏览记录的功能。通过特定的代码实现,可以获取到被长按的Cell。
摘要由CSDN通过智能技术生成

有很多APP需要添加长按手势来进行删除收藏、浏览记录等功能。如何获取到当前手势添加的Cell可以调用如下方法来实现。详细代码如下,标红部分为最主要

#import "ViewController.h"


@interface ViewController ()
<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)UITableView * tableView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createTableView];
    // Do any additional setup after loading the view, typically from a nib.
}
- (void)createTableView{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height - 20)];
    self.tableView.delegate = self;
    self.tableView.dataSource= self;
    [self.view addSubview:self.tableView];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteg
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值