UICollectionViewCell--查找cell上的按钮点击后,对应的是哪个cell
2016-01-19 14:17
399 查看
实际写项目会碰到各种各样的问题,废话不多说
按钮添加到cell时,根据是直接添加到self还是self.contentView上,在点击方法里找到btn的父视图
我是直接添加到self上,所以只有一层
若是代理,则直接将cell传过去便是
按钮添加到cell时,根据是直接添加到self还是self.contentView上,在点击方法里找到btn的父视图
我是直接添加到self上,所以只有一层
- (void)btnClicked:(UIButton *)btn { UIView *v =[btn superview]; UICollectionViewCell *cell = (UICollectionViewCell *)v; NSIndexPath *tapIndexPath = [self.collectionView indexPathForCell:cell]; NSLog(@"%li---%li",tapIndexPath.section,tapIndexPath.row); }
若是代理,则直接将cell传过去便是
相关文章推荐
- IOS UIAlertView和UIAlertController学习记录
- 红警conquer.mix文件
- Android Volley完全解析(三),定制自己的Request
- LeetCode_Implement Queue using Stacks_队列操作
- 95. Unique Binary Search Trees II
- 加载图片的三种方法imageNamed、imageWithContentsOfFile、NSData
- UE4 4.9 - cast modulated shadows causes flickering on IOS dynamic characters
- C# wpf WebBrowser遮挡上层UI的解决办法
- Jenkins+Git 集成测试(build、zip、curl)
- How to Change RabbitMQ Queue Parameters in Production?
- UE3模块化阴影
- UE4 Directional Lights
- UE4 Dynamic Scene Shadows
- Request的getParameter和getAttribute方法的区别
- Request的getParameter和getAttribute方法的区别
- LabWindows/CVI入门之第二章:GUI开发
- Divide and conquer:Moo University - Financial Aid(POJ 2010)
- UIImageView
- 在iOS开发中关于(UIDevice、NSBundle、NSLocale)注意:凡是使用这些控件必须引入“UIKit.h”框架
- UISearchBar becomeFirstResponder不生效解决