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]];

 





免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM