假設每個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]];