点击手势在 imageView 中不起作用,但在另一个视图中起作用

Tap gesture is not working in imageView but it working another view(点击手势在 imageView 中不起作用,但在另一个视图中起作用)
本文介绍了点击手势在 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 中不起作用,但在另一个视图中起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

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

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)