这种方法主要用于工厂cell
- (IBAction)diggCountBut:(UIButton *)sender forEvent:(UIEvent *)event {
//取到 button所在的cell的indexPath
NSSet *touches =[event allTouches];
UITouch *touch =[touches anyObject];
UITableView *tableView = (UITableView *)[[[[sender superview] superview] superview] superview];
CGPoint currentTouchPosition = [touch locationInView:tableView];
NSIndexPath *indexPath= [tableView indexPathForRowAtPoint:currentTouchPosition];
if (indexPath != nil){
//利用通知发送到ViewController里面实现先做的事情
[[NSNotificationCenter defaultCenter] postNotificationName:@"dig" object:sender userInfo:@{@"row":indexPath}];
}
}
网友评论