我有问题,当youtube播放器将全屏进入或在iOS 8中退出全屏时因为这些通知被删除UIMoviePlayerControllerDidEnterFullscreenNotification而且UIMoviePlayerControllerWillExitFullscreenNotification此版本的操作系统版本.
由于我的应用程序项目仅设置为纵向模式,因此在播放时视频不会旋转为横向模式,这在您的设备上观看视频时实际上不太友好.
通常,当视频以全屏模式进入时,用户希望以纵向模式或横向模式观看视频.
这就是我为iOS 7做的方式,它在iOS 8中运行得很完美.
首先,我将AppDelegate.m在我AppDelegate.h调用 videoIsInFullscreen 和函数的boolean属性中设置此函数,
// this in the AppDelegate.h
@property (nonatomic) BOOL videoIsInFullscreen;
// This in my AppDelegate.m to allow landscape mode when the boolean property is set to yes/true.
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
if(self.videoIsInFullscreen == YES)
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
else
{
return UIInterfaceOrientationMaskPortrait;
}
}
Run Code Online (Sandbox Code Playgroud)
然后在我的ViewController.m第一个,我会#import "AppDelegate.h"在这之后,我将在我的viewDidLoad方法中添加一些通知..
-(void)viewDidLoad {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerStarted) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil]; …Run Code Online (Sandbox Code Playgroud) 我正在构建一个只有1个横向视图的iPhone应用程序,所以我想阻止所有其他的景观,我试过这个:
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
但它仍然在旋转