首页 > 移动平台 > 详细

ios开发之-- tableview/collectionview获取当前点击的cell

时间:2017-12-05 13:06:08      阅读:347      评论:0      收藏:0      [点我收藏+]

方法如下:

一般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];
}

仅做记录!

ios开发之-- tableview/collectionview获取当前点击的cell

原文:http://www.cnblogs.com/hero11223/p/7986178.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!