在tableView或者collectionView里如何获得被点击的cell的下标位置
2016-01-04 13:37
381 查看
/**只能用在UITableView里的方法
* indexPathForSelectedRow可以传递被选中的row,此方法可借鉴。
*/
//NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
/**只能用在collectionView里的方法
* 可以获取collectionView当前所有被选中的cell的下标,但是只能获取到第一个位置,需要传入参数来使用。
*/
//NSIndexPath *firstIndexPath = [[self.collectionView indexPathsForVisibleItems] firstObject];
/**用在collectionView里的方法
* 将collectionView在控制器view的中心点转化成collectionView上的坐标,获取collectionView被选中的cell
*/
//CGPoint pInView = [self.view convertPoint:self.collectionView.center toView:self.collectionView];
//NSIndexPath *indexPathNow = [self.collectionView indexPathForItemAtPoint:pInView];
* indexPathForSelectedRow可以传递被选中的row,此方法可借鉴。
*/
//NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
/**只能用在collectionView里的方法
* 可以获取collectionView当前所有被选中的cell的下标,但是只能获取到第一个位置,需要传入参数来使用。
*/
//NSIndexPath *firstIndexPath = [[self.collectionView indexPathsForVisibleItems] firstObject];
/**用在collectionView里的方法
* 将collectionView在控制器view的中心点转化成collectionView上的坐标,获取collectionView被选中的cell
*/
//CGPoint pInView = [self.view convertPoint:self.collectionView.center toView:self.collectionView];
//NSIndexPath *indexPathNow = [self.collectionView indexPathForItemAtPoint:pInView];
相关文章推荐
- 新手自定义view练习实例之 泡泡弹窗
- 汽车之家 砍价软件
- 新手自定义view练习实例之(一) 泡泡弹窗
- linux 添加用户、权限
- git获取网上的项目
- [转]ReactJS入门教程
- 重新认识二分查找算法
- 使用Jenkins搭建持续集成(CI)环境
- Mongodb 数据类型及Mongoose常用CURD
- oracle12c怎么pdb容器不会自动关闭
- Android CountDownTimer 倒计时器
- Brackets 配置
- linux 命令 —— find
- 为何ViewController释放后不走dealloc
- Android端ORM框架——RapidORM
- Jenkins入门系列之——01第一章 Jenkins是什么?
- 鼓捣电视盒子
- 171,.plist文件中字典数据转成程序模型
- SAP R3 采购申请相关简单操作 :附Oracle后台数据库对应表明细。
- AngularJS 表格