Ios 方位景观->;肖像画不是';行不通
我还有一个定位问题。但这是一个非常棘手的问题。 我的RootViewController是一个普通的NavigationControllerIos 方位景观->;肖像画不是';行不通,ios,xcode,uinavigationcontroller,orientation,modalviewcontroller,Ios,Xcode,Uinavigationcontroller,Orientation,Modalviewcontroller,我还有一个定位问题。但这是一个非常棘手的问题。 我的RootViewController是一个普通的NavigationController self.window.rootViewController = _naviController; 里面有另一个ViewController,我们称之为VC1。 VC1有一些按钮和标签。它就像一个文件夹概述 如果我按下一个按钮,我会进入下一个ViewController,其中包含3个ViewController(第页)和另一组按钮(如在文件夹内查看图片/
self.window.rootViewController = _naviController;
里面有另一个ViewController,我们称之为VC1。
VC1有一些按钮和标签。它就像一个文件夹概述
如果我按下一个按钮,我会进入下一个ViewController,其中包含3个ViewController(第页)和另一组按钮(如在文件夹内查看图片/缩略图):
在loadView中:
firstPage = [[Page alloc] initViewWithFrame:CGRectMake(0, 0, 768, 960)];
[firstPage setRootViewController:self];
secondPage = [[Page alloc] initViewWithFrame:CGRectMake(0, -960, 768, 960)];
[secondPage setRootViewController:self];
thirdPage = [[Page alloc] initViewWithFrame:CGRectMake(0, 960, 768, 960)];
[thirdPage setRootViewController:self];
如果我现在再次单击活动页面上的按钮,则会按下我的第三个ViewController(具有调整大小、拖动等功能的图像):
使用NavigationController的BackButton,我可以始终返回到上一个视图
更多信息:
- 每个ViewController都支持所有方向
- 每个ViewController实现
,并返回YES代码>-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- 每个ViewControler在其init方法中调用
[super init]
- 我已经读过了
shouldAutorotateToInterfaceOrientation
正在调用,帧大小和原点正在更改…)。
但是如果我换成另一种方式,我处于横向模式,从第二个VC切换到第三个VC,旋转到纵向,然后使用BackButton返回第二个VC,状态栏和控制器栏位于顶部,但应该自动旋转指针面方向
未调用
请帮帮我$h@rky今天我有了一个想法,在不知道原因的情况下解决了问题。 在我的第三个VC中,我刚刚创建了一个指向第二个视图的指针,并自己调用了
shouldAutorotateToInterfaceOrientation
但要点仍然是一样的:为什么在所描述的情况下,不应该调用autorotateTointerFaceOrientation
亲切的问候$h@rky试试这个,它对我有用:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self shouldAutorotateToInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation] ];
}
应仅在用户旋转时调用AutoRotateTointerFaceOrientation
,因此当您从横向到纵向或以其他方式查看控制器时,控制器仍然是横向的,因此要解决此问题,您必须破解代码,这意味着当您从横向到纵向推送视图控制器时,呈现视图控制器示例:
ListCurrentViewController *list = [self.storyboard
instantiateViewControllerWithIdentifier:@"ListCurrentViewController"];
[self.navigationController presentViewController:list animated:NO completion:Nil];
[list dismissViewControllerAnimated:NO completion:Nil];
[self.navigationController pushViewController:list animated:YES];
在ListViewController函数中调用:
(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation // iOS 6 autorotation fix { return UIInterfaceOrientationPortrait; }
您必须为UINavigationController创建类别
(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return [self.visibleViewController preferredInterfaceOrientationForPresentation];
}
我希望这个解决方案能对你有所帮助 是的,这也很有效,但这并不能回答为什么当我以纵向方向返回时视图没有调用的问题。不管怎样,如果诺多比告诉我下周为什么会发生这种情况,我会接受答案。就像我承诺接受和投票一样,因为决议比我的方式更聪明$h@rky
(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation // iOS 6 autorotation fix { return UIInterfaceOrientationPortrait; }
(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return [self.visibleViewController preferredInterfaceOrientationForPresentation];
}