从 imageview 点击手势获取索引或标签值

get index or tag value from imageview tap gesture(从 imageview 点击手势获取索引或标签值)
本文介绍了从 imageview 点击手势获取索引或标签值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

这是我们搜索任何应用时来自应用商店的图片.我还想添加相同的滚动视图概念,在该概念中它显示当前图像以及上一个和下一个图像的小预览.我能够在 示例代码.但是没有找到当用户点击任何图像时如何获取索引或标记值的任何解决方案.这样我就可以打开每个图像的详细信息页面.如果有人对此有任何想法,请帮助我.

This is the image from app store whenever we search for any app. I also want to add the same scrollview concept in which it show the currentimage with small preview of previous and next image. I am able to make this view with the help of Sample code. But didn't find any solution that how to get index or tagvalue when user tap any of the image. So that I would be able to open the detail page for each image. If Someone has idea about this please help me.

提前致谢.

推荐答案

将手势识别器添加到必要的图像视图中:

Add gesture recognizer to the necessary image view:

UITapGestureRecognizer *frameTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(frameTapGesture:)];
[_imgView addGestureRecognizer:frameTapGesture];

然后在手势处理程序中访问附加到的视图手势识别器:

Then in the gesture handler get access to the view gesture recognizer attached to:

- (void)frameTapGesture:(UITapGestureRecognizer*)sender
{
    UIView *view = sender.view; //cast pointer to the derived class if needed
    NSLog(@"%d", view.tag);
}

这篇关于从 imageview 点击手势获取索引或标签值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

UIButtons at the bottom of UIScrollView not working(UIScrollView 底部的 UIButtons 不起作用)
scrollViewWillEndDragging:withVelocity:targetContentOffset: not working on the edges of a UISCrollView(scrollViewWillEndDragging:withVelocity:targetContentOffset: 不在 UISCrollView 的边缘工作)
ImageView Scaling when scrolling down(向下滚动时 ImageView 缩放)
Bounds automatically changes on UIScrollView with content insets(UIScrollView 上的边界自动更改,带有内容插图)
iOS5 UITapRecognizer for UIScrollView interfering with buttons. How to fix?(用于 UIScrollView 的 iOS5 UITapRecognizer 干扰按钮.怎么修?)
Handling scroll views with (custom, interactive) view controller presentation and dismissal(使用(自定义、交互式)视图控制器呈现和解除处理滚动视图)