当用户点击UIView(全屏)时,我的应用需要检测方向并执行一些操作。但是有一个小问题。 如果我以横向模式启动应用程序,并且用户点击背景'interfaceOrientation'变量为'0',并且我不知道如何重新排列视图元素。如果我旋转模拟器一旦一切都很好,但如果不'interfaceOrientation'是'0'。在这里做什么?iPad界面方向问题
UIInterfaceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];
if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
...
}
else if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
...
}
else if(interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
...
}
你是从视图控制器的viewDidLoad调用'[super viewDidLoad]'吗? – highlycaffeinated
是的,我叫它,但它仍然是'0' – 1110
如果你在你的'viewDidLoad'中向'[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]添加了一个调用,会发生什么? – highlycaffeinated