IOS 6 和 IOS7 UITableViewCell上添加控件的获取

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

IOS6上blog

-(IBAction)btnClick:(id)sender

{

  UIButton *btn = (UIButton *)sender;

  UITableViewCell *cell = [btn superView];

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

  xxxx

}

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

UITableViewCellScrollView

,那么IOS7怎么获取呢?能够按照这样的方法table

设置每一个按钮的Tag

cell = (UITableViewCell*)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:btn.tag inSection:0]];
相关文章
相关标签/搜索