【发布时间】:2011-11-08 23:26:14
【问题描述】:
我的应用程序有导航栏,其中第一个屏幕返回“是”方向,第二个屏幕根据用户在第一个屏幕中选择的内容设置为某个方向。从第 2 个屏幕返回第 1 个屏幕后,如果用户手持设备为纵向但界面为横向,则第 1 个屏幕设置为横向。发生这种情况是因为
(BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation
仅在更改设备方向后调用。
我想检查什么是设备方向 atm 并将界面方向设置为此。 试过了:
//1st method:
UIViewController *rotateTheScreen = [[UIViewController alloc]init];
[self presentModalViewController:rotateTheScreen animated:NO];
[self dismissModalViewControllerAnimated:NO];
[rotateTheScreen release];
//2nd method:
UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation;
//3rd method:
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
第一个表现得很奇怪,除了从界面方向=横向和设备方向=横向返回之外,旋转所有情况(这是一个错误,他旋转到横向) 第二次检查界面,就像名字所说的那样,但对我的问题不起作用 据我所知,第三个是私有的,Apple 拒绝使用它的应用程序。
【问题讨论】:
标签: iphone objective-c ios orientation