gpt4 book ai didi

iphone - 在电影播放器​​上按“完成”后恢复纵向?

转载 作者:行者123 更新时间:2023-11-29 11:20:38 25 4
gpt4 key购买 nike

我有一个正在运行的 MPMoviePlayer。它旨在将邮票大小的电影显示为 View 中的 subview 。当手机旋转成横向时,它会进入全屏模式。当手机处于纵向时,它会进入邮票纵向模式。

唯一的问题是,当我在横向模式下按“完成”时,它仍然是横向的,带有邮票大小的电影,而不是回到纵向。

这是我的一些代码:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 


if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
[moviePlayerController setFullscreen:YES animated:YES];
} else
{
[moviePlayerController setFullscreen:NO animated:YES];

}


}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

return interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeLeft;

}

我如何让它在按下“完成”后进入纵向模式?

最佳答案

@cannyboy...如果您的应用程序仅适用于纵向模式,您只需在 APPDelegate.m 中使用以下方法

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
if ([[window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]])
{
//NSLog(@"in if part");
return UIInterfaceOrientationMaskAllButUpsideDown;
}
else
{
//NSLog(@"in else part");
return UIInterfaceOrientationMaskPortrait;
}}

关于iphone - 在电影播放器​​上按“完成”后恢复纵向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7407567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com