objective-c - 如何在 IOS6 中的全屏模式 MPMoviePlayerController 上添加滑动手势

标签 objective-c ios6 mpmovieplayercontroller fullscreen gesture

我尝试向 player.view.subviews[0] 添加滑动手势。

我用谷歌搜索了很多次,但找不到有效的解决方案。

我的代码很正常。就像

UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeAction:)];
UIView *subView = player.view.subviews[0];
[subView addGestureRecognizer:swipeLeft];

当播放器处于全屏模式时,它在 IOS5 中有效,但在 6 中无效。 有什么建议吗?

最佳答案

当 Mpmovieplaertsontroller 进入全屏模式时,它会创建一个附加窗口(通常是应用程序窗口列表中的最后一个窗口)。由此我们可以测试所有可能的 View 和 subview 并找到必要的控件。然后你就可以放置你需要的一切了。 例如,如何向 MPMoviePlayer 添加滑动。

- (void)didEnterFullScreen:(NSNotification*)notification {
    [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(showFullScreenControls) userInfo:nil repeats:NO];
}

- (void)showFullScreenControls {
    NSArray *windows = [[UIApplication sharedApplication] windows];
    UIWindow* mpfullscreenwindow = [windows lastObject];
    gestureView = mpfullscreenwindow.subviews[0];
    testbutton = [UIButton buttonWithType:UIButtonTypeSystem];
    [testbutton setTitle:@"Test" forState:UIControlStateNormal];
    testbutton.frame = CGRectMake(10, 50, 100, 50);
    testbutton.backgroundColor = [UIColor greenColor];
    [testbutton addTarget:self action:@selector(alertBtnAction) forControlEvents: UIControlEventTouchUpInside];
    [mpfullscreenwindow addSubview:testbutton];
    [gestureView addGestureRecognizer:_leftSwipeRecognizer];
    [gestureView addGestureRecognizer:_rightSwipeRecognizer];
}

关于objective-c - 如何在 IOS6 中的全屏模式 MPMoviePlayerController 上添加滑动手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17247173/

相关文章:

ios - 基于另一个属性值的属性默认值

ios - MPMoviePlayer - 黑屏 - iOS 5 - 没有视频播放

iphone - MPMoviez PlayerViewController 在 5.1 下无法横向播放

objective-c - 在Xcode中组织大型Cocoa应用程序源代码的最佳方法是什么?

ios - 设置按钮的标签值以在单元格单击时取消隐藏

ios - Facebook SDK 3.0 IOS 6 登录后回调未调用

ios - 在iOS 7之前,如果不涉及音频、位置等,是否可以执行后台任务

xcode - iOS 6.0 Apple LLVM 编译器 4.1 错误

ios - MPMoviePlayerController-Xcode找不到它和屏幕

objective-c - 排序时忽略标点符号(Objective-C)