gpt4 book ai didi

ios - 点击手势在 imageView 中不起作用,但它在另一个 View 中起作用

转载 作者:行者123 更新时间:2023-11-29 10:33:06 24 4
gpt4 key购买 nike

我在图像和视频叠加层中工作,因为我放置了一个 ImageView ,我将 tapGestureRecognizer 分配给该 ImageView 它不起作用,对于视频我放置了一个 MPMoviePlayerController 并将 tapGestureRecognizer 设置为它,这个工作正常但是仅 ImageView 不起作用。下面是我的代码

- (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];

使用它可能会帮助你......

关于ios - 点击手势在 imageView 中不起作用,但它在另一个 View 中起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28542228/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com