点按手势在imageView中不起作用,但它在另一个视图中工作 [英] Tap gesture is not working in imageView but it working another view

查看:121
本文介绍了点按手势在imageView中不起作用,但它在另一个视图中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在图像和视频叠加工作,我放了一个图像视图,我将tapGestureRecognizer分配给该图像视图它不工作,对于视频我放了一个MPMoviePlayerController我设置tapGestureRecognizer到它这一个工作正常,但是图片视图只是不工作.Below是我的代码

i have working in image and video overlay in that i put one image view, i assigned the tapGestureRecognizer to that image view its not working,For video i put one MPMoviePlayerController and i set the tapGestureRecognizer to it this one working fine but the image view only not working.Below is my code

- (void)viewDidLoad {
    [super viewDidLoad];
    videoimg=[[UIImageView alloc]init];//OvelayImage
    videoimg.image=[UIImage imageNamed:@"fb.png"];
    videoimg.userInteractionEnabled=YES;
    videoimg.multipleTouchEnabled=YES;
    [self.imgView bringSubviewToFront:videoimg];

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imagePan:)];

    tap.numberOfTapsRequired=1;
    tap.numberOfTouchesRequired=1;

    [videoimg addGestureRecognizer:tap];
    [self.imgView addSubview:videoimg];//add the overlay image to Main imageView 
    [self.videoPlayerView.view addSubview:videoimg];//MPMoviePlayerController-add the overlay image to VideoView
}

//Gesture
-(void)imagePan:(UITapGestureRecognizer*)ges{

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Image" message:@"FB Image Clicked..."
                                                   delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
}


推荐答案

videoimg=[[UIImageView alloc]init];
videoimg.image=[UIImage imageNamed:@"fb.png"];
videoimg.userInteractionEnabled=YES;

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imagePan:)];
[videoimg setGestureRecognizers:[NSArray arrayWithObject:tap]];
tap.numberOfTapsRequired=1;
[self.videoPlayerView.view addSubview:videoimg];

使用它可能对你有帮助....

use it may help you....

这篇关于点按手势在imageView中不起作用,但它在另一个视图中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆