0
当我点击我的MPMoviePlayerController
时,没有任何反应。任何人都可以看到我在设置UITapGestureRecognizer
时做错了什么?向MPMoviePlayerController添加UITapGestureRecognizer
- (void) playMovie : (NSString *) urlString{
self.movieURLString = urlString;
NSURL *movieURL = [NSURL URLWithString:self.movieURLString];
self.moviePlayer = [[MPMoviePlayerController alloc] init];
[self.moviePlayer setShouldAutoplay:YES];
[self.moviePlayer setContentURL:movieURL.absoluteURL];
[self.moviePlayer setMovieSourceType:MPMovieSourceTypeFile];
self.moviePlayer.controlStyle = MPMovieControlStyleNone;
self.moviePlayer.view.frame = self.movieView.frame;
/* add tap handler */
UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showControls:)];
singleFingerTap.delegate = self;
//EDIT: this line somehow didn't make into my OP
[self.moviePlayer.view addGestureRecognizer:singleFingerTap];
self.moviePlayer.view.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.moviePlayer.view];
[self.moviePlayer prepareToPlay];
// respond to changes in movie player status
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(myMovieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.moviePlayer];
}
- (void) showControls : (UITapGestureRecognizer *) recognizer {
NSLog(@"here");
self.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
}
我没有检查你的文章的细节,但我想你错过了'MPMoviePlayerController'本身使用几个手势识别器的事实,你的永远不会因为冲突而被触发。 – Till 2014-09-20 20:37:51