UIButton* coverButton = [UIButton buttonWithType:UIButtonTypeCustom];
coverButton.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[coverButton addTarget:self action:@selector(clickGesture:event:) forControlEvents:UIControlEventTouchUpInside];
[cell addSubview:coverButton];
-(void)clickGesture:(id)sender event:(id)event{
//获取点击的位置
NSSet* set = [event allTouches];
UITouch* touch = [set anyObject];
CGPoint point = [touch locationInView:self.tableView];
NSIndexPath* indexPath = [self.tableView indexPathForRowAtPoint:point];
NSLog(@"point.x: %f point.y : %f",point.x,point.y);
if (point.x < self.view.frame.size.width / 3) {
// NSLog(@"point.x < 1/3");
}
else if(point.x > self.view.frame.size.width / 3 * 2){
// NSLog(@"point.x > 2/3");
}
else{
// NSLog(@"1/3 <point.x < 2/3");
}
NSLog(@"index row:%d", indexPath.row);
}