使用MPMoviePlayerController的视图后,UITouch被阻止

时间:2012-07-09 19:44:09

标签: ios uiview mpmovieplayercontroller uitouch

屏幕左上角有一个UIButton。使用iOS模拟器,我可以轻松触摸按钮最左上角的部分。它按预期工作:

enter image description here

但是在使用MPMoviePlayerController后,按钮在该区域按下时不起作用! (可以更大/更小)。听起来很疯狂!

MPMoviePlayerController代码:

if (!_player) {
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];        

    NSError *setCategoryErr = nil;
    NSError *activationErr  = nil;
    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryErr];
    [[AVAudioSession sharedInstance] setActive: YES error: &activationErr];

    VCRoot* root = [[ApplicationManager sharedManager] rootViewController];

    _player = [[MPMoviePlayerController alloc] init];
    _player.movieSourceType = MPMovieSourceTypeStreaming;
    _player.view.hidden = YES;
    [root.view addSubview:_player.view];

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(moviePlayerStateChanged:) 
                                                 name:MPMoviePlayerLoadStateDidChangeNotification 
                                               object:nil];
} else {
    [_player stop];
}

_player.contentURL = [channel url];

[_player setInitialPlaybackTime:-1.0];
[_player play];

注:

我尝试使用_player.view添加insertSubview: AtIndex:0,尝试setIsUserInteractionEnabled = NO,尝试setAlpha = 0.f,一切都没有用。我甚至将其添加为不同视图的子视图。

但是:

当我停止播放器并删除视图时,该区域可再次触摸:(

1 个答案:

答案 0 :(得分:0)

我试过的所有事情......最后:

_player.view.frame = CGRectMake(-100, -100, 1.f, 1.f);

工作!