【发布时间】:2013-05-02 20:53:04
【问题描述】:
我只想在我的 iOS 应用程序的所有视图控制器中支持垂直方向。 However, I embed a YouTube video in one of my view controllers, and when that video is selected to take up the full screen, I want the user to be able to orient his/her phone horizontally so the video expands to take the full screen .
编辑:我尝试使用来自Autorotate in iOS 6 has strange behaviour 的以下代码:
- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return self.fullScreenVideoIsPlaying ?
UIInterfaceOrientationMaskAllButUpsideDown :
UIInterfaceOrientationMaskPortrait;
}
在呈现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);
}
但是,当用户在全屏 YouTube 视频上按下完成时,如果他/她仍然将手机水平放置,那么当前视图控制器也保持水平(我希望当前视图控制器是纵向的)。这是fullSreenVideoIsPlaying 变量的竞赛,它的更新速度不够快,因此我的呈现视图控制器是纵向的。
我们将不胜感激任何有关如何实现这一目标的反馈。
谢谢!
【问题讨论】:
-
你可以阅读-buddingdevelopers.com/autorotation-in-ios这里清楚地解释了自动旋转。
标签: ios objective-c ios6 uiviewcontroller autorotate