- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UIButton *deleBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - WIDTH(76), 25, WIDTH(76), HEIGHT(36))];
[deleBtn setBackgroundImage:[UIImage imageNamed:@"dierbu-shanchu.png"]
forState:UIControlStateNormal];
//添加响应事件.
[deleBtn addTarget:self action:@selector(deletBtnTap: event:) forControlEvents:UIControlEventTouchUpInside];
- }
// 点击方法
- (void)deletBtnTap:(UIButton *)sender event:(id)event{
NSSet *touches=[event allTouches];
UITouch *touch=[touches anyObject];
CGPoint cureentTouchPosition=[touch locationInView:self.tableView];
//得到indexPath
NSIndexPath *indexPath=[self.tableView indexPathForRowAtPoint:cureentTouchPosition];
NSLog(@"section----%ld,----row---%ld",indexPath.section,indexPath.row);
// 接下来可以根据section&Row来进行操作了
switch(section){
case row:
{
break;
}
default:
break;
}
}
iOS 点击Tableview中的Button来确定Section和Row
最新推荐文章于 2019-04-02 22:02:41 发布
本文介绍了一个自定义UITableViewCell的方法,在该方法中为UITableViewCell添加了一个删除按钮,并实现了点击删除按钮后的响应事件处理。通过设置按钮的位置、样式及绑定点击事件,使得在表格视图中可以方便地进行删除操作。
688

被折叠的 条评论
为什么被折叠?



