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



  • 相关阅读:
    从头学Android之Android布局管理:LinerLayout线性布局
    Android onTouch事件传递机制
    android开源项目和框架
    <hdu
    <hdu
    <poj
    <poj
    <hdu
    <hdu
    <hdu
  • 原文地址:https://www.cnblogs.com/iosdev/p/3398257.html
Copyright © 2020-2023  润新知