ios – MPMoviePlayerController的视图无法识别触摸

ios – MPMoviePlayerController的视图无法识别触摸,第1张

概述这是我的代码: _mediaPlayer = [[MPMoviePlayerController alloc] init];_mediaPlayer.controlStyle = MPMovieControlStyleNone;_mediaPlayer.shouldAutoplay = NO;[_mediaPlayer.view setFrame: CGRectMake(5, 5, 600, 这是我的代码:

_mediaPlayer = [[MPMovIEPlayerController alloc] init];_mediaPlayer.controlStyle = MPMovIEControlStyleNone;_mediaPlayer.shouldAutoplay = NO;[_mediaPlayer.vIEw setFrame: CGRectMake(5,5,600,400)];[playerHolder addSubvIEw: _mediaPlayer.vIEw];//[self prepareScreenContenttoplay];//UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleRollTap:)];singleFingerTap.numberOfTapsrequired = 1;[_mediaPlayer.vIEw addGestureRecognizer:singleFingerTap];[singleFingerTap release];

手势识别器的动作方法:

-(voID)handleRollTap:(UITapGestureRecognizer*)sender{    NSLog(@"%@",@"touch");}

MPMovIEPlayerController工作正常。另外我想处理触摸MPMovIEPlayerController视图,但handleRollTap从未调用。为什么MPMovIEPlayerController的视图不能与UITapGestureRecognizer一起使用?

好。如果singleFingerTap.numberOfTapsrequired = 2;那么所有的工作也很好。但没有一点点击..

解决方法 其实回答这个很简单:

>将自己设置为UIGestureRecognizer委托
>为代理方法返回YES:

例如

UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture)];tapGestureRecognizer.delegate = self;

和代码中的其他地方:

#pragma mark - gesture delegate// this allows you to dispatch touches- (BOol)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceivetouch:(UItouch *)touch {return YES;}// this enables you to handle multiple recognizers on single vIEw- (BOol)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {return YES;}
总结

以上是内存溢出为你收集整理的ios – MPMoviePlayerController的视图无法识别触摸全部内容,希望文章能够帮你解决ios – MPMoviePlayerController的视图无法识别触摸所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1086996.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存