UITableViewCell每行中的UIButton轻松获得cell的IndexPath
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];button.frame = CGRectMake(0.0, 0.0, 100, 100);// set the button's target to this table view controller so we can interpret touch events and map that to a NSIndexSet[button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside];cell.accessoryView = button;- (void)checkButtonTapped:(id)sender event:(id)event{NSSet *touches = [event allTouches];UITouch *touch = [touches anyObject];CGPoint currentTouchPosition = [touch locationInView:self.tableView]; NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition];if (indexPath != nil){}}