g.r*_*ion 12 iphone objective-c mpmovieplayercontroller ios ios6
这个问题只是我问题的一部分.我正在为我现有的应用程序实现iOS6轮换和方向支持.
所以我有一个ViewController,它包含一个嵌入在ViewController视图中的MPMoviePlayerController(我的应用程序需要它).用户可以播放视频并在嵌入视图中查看,或使用默认播放器控件单击全屏按钮,播放器进入全屏模式.
现在我已经将视图控制器限制为仅使用iOS6提供的新旋转API支持纵向方向.
// New Autorotation support.
- (BOOL)shouldAutorotate;
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
这非常有效.ViewController仅支持纵向和用户在嵌入视图中播放影片.
现在问题出现了,当用户进入全屏模式时.在全屏模式下,当我旋转模拟器/设备时,电影将继续旋转.当我而影片在全屏模式下播放与断点旋转设备shouldAutorotate和supportedInterfaceOrientations,它仍然来自这些都方法,返回NO和UIInterfaceOrientationMaskPortrait分别,但仍电影旋转...
为什么会这样?....这是我的问题的一部分......第二部分是我希望当用户进入全屏模式时电影以横向模式进入.我希望电影播放器锁定横向模式,直到用户按下DONE按钮.
请帮忙 ....
Hin*_*ndu 22
你可以尝试以下功能AppDelegate:
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
}
Run Code Online (Sandbox Code Playgroud)
你可以为这两种模式创造条件.
例如,如果媒体播放器是全屏幕的话
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
除此以外 return UIInterfaceOrientationMaskPortrait;
我没试过,但我想,它应该适用于你的情况.
谢谢
为清楚起见,这里是完整的代码(它全部进入你的app代理):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(willExitFullscreen:)
name:MPMoviePlayerWillExitFullscreenNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(willEnterFullscreen:)
name:MPMoviePlayerWillEnterFullscreenNotification
object:nil];
}
- (void)willEnterFullscreen:(NSNotification*)notification
{
NSLog(@"willEnterFullscreen");
isFullScreen = YES;
}
- (void)willExitFullscreen:(NSNotification*)notification
{
NSLog(@"willExitFullscreen");
isFullScreen = NO;
}
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (isFullScreen)
return UIInterfaceOrientationMaskLandscapeLeft;
else
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
isFullScreen是要在AppDelegate.h中声明的BOOL
| 归档时间: |
|
| 查看次数: |
11770 次 |
| 最近记录: |