Objective c 只有一个控制器的iOS6横向应用程序多方向popViewController问题
在大多数ViewController中,我的设置仅支持横向 我的应用程序代理有以下代码:Objective c 只有一个控制器的iOS6横向应用程序多方向popViewController问题,objective-c,ios6,orientation,Objective C,Ios6,Orientation,在大多数ViewController中,我的设置仅支持横向 我的应用程序代理有以下代码: -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { NSUInteger orientations = UIInterfaceOrientationMaskLandscape; if (self.window.r
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
NSUInteger orientations = UIInterfaceOrientationMaskLandscape;
if (self.window.rootViewController) {
UIViewController * pressented = [[((UINavigationController *)self.window.rootViewController) viewControllers] lastObject];
orientations =[pressented supportedInterfaceOrientations];
}
return orientations;
}
在大多数视图控制器中:
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
当我按下此控制器(我要旋转的控制器)时,我的问题出现了:
它的旋转非常完美,但当我以纵向方向弹出viewcontroller(点击导航栏的后退按钮)时,显示viewcontroller也会将其方向设置为纵向
如何使显示的viewcontroller保持在横向锁定状态,或在弹出前强制有问题的控制器旋转回横向 将此添加到纵向视图控制器:
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
UIViewController* dummyController = [[UIViewController alloc] init];
[self presentViewController:dummyController animated:NO completion:^{
[self dismissViewControllerAnimated:NO completion:nil];
}];
}
我知道这是一个黑客,但它的工作。有人知道更好的解决办法吗
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
UIViewController* dummyController = [[UIViewController alloc] init];
[self presentViewController:dummyController animated:NO completion:^{
[self dismissViewControllerAnimated:NO completion:nil];
}];
}