适用于youtube嵌入式视频的iOS 6.0自动旋转

适用于youtube嵌入式视频的iOS 6.0自动旋转,第1张

概述我想只在我的iOS应用程序的所有视图控制器中支持垂直方向.但是,我在我的一个视图控制器中嵌入了一个YouTube视频,当选择该视频占据整个屏幕时,我希望用户能够水平定位他/她的手机,以便视频扩展为全屏. 编辑:我尝试使用Autorotate in iOS 6 has strange behaviour中的以下代码: - (NSUInteger) application:(UIApplication 我想只在我的iOS应用程序的所有视图控制器中支持垂直方向.但是,我在我的一个视图控制器中嵌入了一个YouTube视频,当选择该视频占据整个屏幕时,我希望用户能够水平定位他/她的手机,以便视频扩展为全屏. @H_403_2@编辑:我尝试使用Autorotate in iOS 6 has strange behaviour中的以下代码:

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrIEntationsForWindow:(UIWindow *)window {return self.fullScreenVIDeoIsPlaying ?    UIInterfaceOrIEntationMaskAllButUpsIDeDown :    UIInterfaceOrIEntationMaskPortrait;
@H_403_2@}

@H_403_2@在我的视图控制器中显示UIWebVIEw / YouTube框架,我在vIEwDIDLoad中有这个代码:

[[NSNotificationCenter defaultCenter]     addobserver:self     selector:@selector(windowNowVisible:)     name:UIWindowDIDBecomeVisibleNotification     object:self.vIEw.window];- (voID)windowNowVisible:(NSNotification *)notification{    AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];    appDelegate.fullScreenVIDeoIsPlaying = !(appDelegate.fullScreenVIDeoIsPlaying);}
@H_403_2@然而,当用户在全屏YouTube视频上按下完成时,如果他/她仍然水平地具有电话,则呈现视图控制器也保持水平(我希望当前视图控制器是肖像).这是fullSreenVIDeoIsPlaying变量的竞赛,它没有足够快地更新,因此我的呈现视图控制器是纵向的.

@H_403_2@任何有关如何实现这一目标的反馈将不胜感激.

@H_403_2@谢谢!

解决方法 通过将我在StackOverflow上找到的一些解决方案组合在一起来找出解决方案. @H_403_2@而不是使用此通知

[[NSNotificationCenter defaultCenter]      addobserver:self      selector:@selector(windowNowVisible:)      name:UIWindowDIDBecomeVisibleNotification      object:self.vIEw.window ];
@H_403_2@我使用以下通知

[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(youTubeStarted:) name:@"UIMovIEPlayerControllerDIDEnterFullscreenNotification" object:nil];     [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(youTubeFinished:) name:@"UIMovIEPlayerControllerWillExitFullscreenNotification" object:nil];
@H_403_2@与实现

-(voID) youTubeStarted:(NSNotification*) notif {     AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];     appDelegate.fullScreenVIDeoIsPlaying = YES;} -(voID) youTubeFinished:(NSNotification*) notif {     AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];     appDelegate.fullScreenVIDeoIsPlaying = NO; }
@H_403_2@在我的AppDelegate中,我有

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrIEntationsForWindow:(UIWindow *)window{     NSUInteger orIEntations = UIInterfaceOrIEntationMaskPortrait;     if (self.fullScreenVIDeoIsPlaying) {         return UIInterfaceOrIEntationMaskAllButUpsIDeDown;     }     else {                 if(self.window.rootVIEwController){             UIVIEwController *presentedVIEwController = [[(UINavigationController *)self.window.rootVIEwController vIEwControllers] lastObject];             orIEntations = [presentedVIEwController supportedInterfaceOrIEntations];     }return orIEntations; }
@H_403_2@在我看来,控制器,我有

-(BOol) shouldautorotate {     return NO; } -(NSUInteger)supportedInterfaceOrIEntations{     return UIInterfaceOrIEntationMaskPortrait; } - (UIInterfaceOrIEntation)preferredInterfaceOrIEntationForPresentation{     return UIInterfaceOrIEntationPortrait; }
总结

以上是内存溢出为你收集整理的适用于youtube嵌入式视频的iOS 6.0自动旋转全部内容,希望文章能够帮你解决适用于youtube嵌入式视频的iOS 6.0自动旋转所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存