您的位置:首页 > 产品设计 > UI/UE

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

2013-10-30 23:33 603 查看
假设每个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]];

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: