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

假设每个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]];

 




posted on 2013-10-30 23:33  小浪鼓  阅读(5246)  评论(0编辑  收藏  举报

导航