zoukankan      html  css  js  c++  java
  • 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]];
    



  • 相关阅读:
    asp.net读取/导入project(mpp)文件
    hdu2103
    hdu2100(大数加)
    hdu1406
    hdu1249
    hdu1038
    hdu2565
    hdu1203
    zoj3501
    hdu2102
  • 原文地址:https://www.cnblogs.com/iosdev/p/3398257.html
Copyright © 2011-2022 走看看