本文介绍了点击手势在 imageView 中不起作用,但在另一个视图中起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在图像和视频叠加中工作,因为我放置了一个图像视图,我将 tapGestureRecognizer 分配给该图像视图它不起作用,对于视频,我放置了一个 MPMoviePlayerController 并将 tapGestureRecognizer 设置为它,这个工作正常但是图像视图仅不起作用.以下是我的代码
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 中不起作用,但在另一个视图中起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!