Ios- Ipad- UicollectionViewCell- 单元格上的图标- 如何在 xcode 5 中向图标添加点击手势?

标签 ios iphone objective-c ipad

我使用了一个 Collection View 单元格来显示多个图像。然后每张图片的右上角都会有一个小图标。我的问题是如何将点击手势添加到每个单元格图像右上角的小图标。

我的代码:

UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(projectSetting:)];
_projectSettingIconButton = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login-settings.png"]]; 
_projectSettingIconButton.frame = CGRectMake(95, 3, 21, 21); 
[_projectSettingIconButton addGestureRecognizer:tapped]; 
[cell addSubview:_projectSettingIconButton]; 

最佳答案

试试这个

在图标上添加点击手势识别器:

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];        
[YOURICON addGestureRecognizer:singleTap];

然后添加

-(void)handleSingleTap:(id)sender
{
    // do your stuff;
}

关于Ios- Ipad- UicollectionViewCell- 单元格上的图标- 如何在 xcode 5 中向图标添加点击手势?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22171848/

相关文章:

ios - 检测垂直或水平位置 iOS

iphone - 有人可以解释如何使用 fmdb 的 FMDatabaseQueue 吗?

iphone - 在 iPhone 中使用 AVFoudation 连续捕获图像

objective-c - 创建 UIImageView

ios - Swift 3 Facebook 登录

iOS self.navigationController.toolbar 位置到顶部没有改变

iOS,人脸检测,检测远离人脸的位置

ios - 你怎么称呼这个在 iOS 中查看的堆叠文件夹?

objective-c - 是否可以通过编程方式确定类具有哪些属性?

ios - NSURLConnection的奇怪错误代码4294966295