zoukankan      html  css  js  c++  java
  • ios开发之-- tableview/collectionview获取当前点击的cell

    方法如下:

    一般collectionView 或者 tableview都有自带的点击函数,如下:
    1, collectionView
       -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    //一般情况,cell不是自定义
        UICollectionViewCell * cell = (UICollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath]; //即为要得到的cell
    //自定义的cell
       TitleViewCell * cell = (TitleViewCell *)[self collectionView:collectionView cellForItemAtIndexPath:indexPath];//即为要得到的cell
    }
    2,tableView
    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    //非自定义cell
        UITableViewCell * cell = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
     //自定义cell
         NewsTableViewCell * cell = (NewsTableViewCell *)[self tableView:tableView cellForRowAtIndexPath:indexPath];
    }

    仅做记录!

  • 相关阅读:
    获取父类参数类型工具类
    date工具类
    Ascii工具类
    AES加解密工具类
    请求ip获取工具类
    对象和map互相转换工具类
    HTTP中get、post请求工具类
    时间日期各种工具类
    算法练习题——两数相除
    ETag
  • 原文地址:https://www.cnblogs.com/hero11223/p/7986178.html
Copyright © 2011-2022 走看看