【问题标题】:Rotate when enters a video in iOS 8在 iOS 8 中输入视频时旋转
【发布时间】:2014-11-19 13:33:56
【问题描述】:

我在 iOS 7 中实现了这段代码并且运行良好,但在 iOS 8 中它不起作用

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeStarted:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeFinished:) name:@"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];

-(void)youTubeStarted{
    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
    appDelegate.fullScreenVideoIsPlaying = YES;
}

-(void)youTubeFinished{
    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
    appDelegate.fullScreenVideoIsPlaying = NO;
}

我尝试将 UIMoviePlayerControllerDidEnterFullscreenNotification 更改为 MPMoviePlayerWillEnterFullscreenNotification。没有运气

还有其他方法吗?

编辑

看看我对 iOS 8.1 的看法,使用 NorthBlast 的答案。它与 iOS 8.0 和 iOS 8.0.2 完美配合

【问题讨论】:

  • 如果您找到答案/解决方案,请告诉我。我也有同样的问题
  • @NorthBlast 你找到解决方案了吗?还是有同样的问题
  • 是的,我做了,但不是为 WillExit.. 我有一个可以作为 DidExit.. 我会发布它..
  • 我认为您现在遇到的问题是布局问题而不是通知问题,但我今晚会检查它..

标签: ios objective-c ios8 nsnotificationcenter


【解决方案1】:

好的,这是一个解决方案,我现在正在使用.. 我首先检查哪个操作系统正在运行该设备,然后为它使用适当的 NSNotificationCenter :)

#define IS_OS_6_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0)
#define IS_OS_8_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)

if(IS_OS_6_OR_LATER){

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeStarted:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeFinished:) name:@"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];

}

if (IS_OS_8_OR_LATER) {

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeStarted:) name:UIWindowDidBecomeVisibleNotification object:self.view.window];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeFinished:) name:UIWindowDidBecomeHiddenNotification object:self.view.window];

}

希望对你有帮助!

【讨论】:

  • 我遇到了和@ElioMB 一样的错误,我们可以在这里做什么?
  • 我试过了,很好用!但是如何锁定其他视图控制器的方向
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-26
  • 2014-11-10
  • 2014-12-01
  • 1970-01-01
相关资源
最近更新 更多