- (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-01-29 17:04:39 发布