如何避免iOS 8中Xcode的自动旋转?
我正在使用Xcode,更新到iOS 8后,如何避免iOS 8中Xcode的自动旋转?,xcode,ios8,autorotate,Xcode,Ios8,Autorotate,我正在使用Xcode,更新到iOS 8后,shouldAutorotate功能不起作用。 我不希望我的viewcontroller自动旋转 如何在iOS 8中从Xcode限制自动旋转?遵循以下步骤: 首先,在info.plist中选择应用程序支持的方向。这意味着如果应用程序仅在纵向模式下显示,则选择纵向作为唯一设置 如果要从appdelegate限制此方向,可以添加以下代码 - (NSUInteger)application:(UIApplication *)application suppo
shouldAutorotate
功能不起作用。
我不希望我的viewcontroller
自动旋转
如何在iOS 8中从Xcode限制自动旋转?遵循以下步骤:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
NSUInteger orientations;
UIViewController* presented = [[[[NavigationManager sharedManager ] navigationController] viewControllers] lastObject];
orientations = [presented supportedInterfaceOrientations];
return orientations;
}
@interface BaseViewController : UIViewController{
}
BaseViewController.m
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
NSUInteger orientations;
UIViewController* presented = [[[[NavigationManager sharedManager ] navigationController] viewControllers] lastObject];
orientations = [presented supportedInterfaceOrientations];
return orientations;
}
@interface BaseViewController : UIViewController{
}
BaseViewController.m
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
在导航控制器类中添加以下代码
在导航控制器类中添加以下代码
你不可能用谷歌搜索这个。。。您只需在“目标”>“常规”设置中选择要支持的方向。@CW0007007您似乎可以推断OP在所有情况下都要限制自动旋转。@Maple您似乎可以推断他们不需要。您可以选择您想要的方向,但一旦选择,您就不能旋转,这就是我需要的……您不能用谷歌搜索这个。。。您只需在“目标”>“常规”设置中选择要支持的方向。@CW0007007您似乎推断OP在所有情况下都要限制自动旋转。@Maple您似乎推断它们不需要。您可以选择您想要的方向,但一旦选择,您就不能旋转,这就是我需要的。。。