假设每个cell上面都有UIButton,怎么判断哪个Cell上的按钮被按下了呢?

IOS6上

-(IBAction)btnClick:(id)sender

{

  UIButton *btn = (UIButton *)sender;

  UITableViewCell *cell = [btn superView];

  NSIndexPath *index = [self.tableView indexPathForCell:cell];

  xxxx

}

 IOS7上同样的方式你会发现btn的superView变成了

UITableViewCellScrollView

,那么IOS7怎么获取呢?可以按照这样的方法

设置每个按钮的Tag

cell = (UITableViewCell*)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:btn.tag inSection:0]];

 




相关文章: