【发布时间】:2013-10-17 03:11:09
【问题描述】:
我在 ios 7 之前使用此代码阻止旋转(我也使用 xibs,现在是故事板)
- (BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationPortrait;
}
现在我迁移到故事板并且 ios7 无法正常工作,我的视图仍在旋转。
更新: 我通过将此代码添加到委托来解决了这个问题,现在我以前的代码就像魅力一样工作
- (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;
}
【问题讨论】:
标签: iphone objective-c uiview rotation