UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(cell.frame.size.width-70,20, 50.0f, cell.frame.size.height-60);
[btn setTitle:@"预约" forState:UIControlStateNormal];
btn.backgroundColor =[UIColor redColor];
[btn addTarget:self action:@selector(cellBtnClicked:event:) forControlEvents:UIControlEventTouchUpInside];
//[btn3 addTarget:self action:@selector(onClick3:) forControlEvents:UIControlEventTouchUpInside];
//btn3.tag=indexPath.row;
[cell.contentView addSubview:btn];
- (void)cellBtnClicked:(id)sender event:(id)event {
NSSet *touches =[event allTouches];
UITouch *touch =[touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:_tableView];
NSIndexPath *indexPath= [_tableView indexPathForRowAtPoint:currentTouchPosition];
if (indexPath!= nil) {
// do something
NSLog(@"%zd",indexPath.row);
}
}
//-(void)onClick3:(UIButton *) sender{
// NSLog(@"%ld",sender.tag);
//}