iPhone / iPad App定位
我的应用程序的iPhone版本支持 UIDeviceOrientationPortraitUpsideDown
和 UIDeviceOrientationPortrait
,但iPad版本支持所有方向。
The iPhone version of my app supports UIDeviceOrientationPortraitUpsideDown
and UIDeviceOrientationPortrait
, but the iPad version supports all Orientations.
在我的视图控制器中我有这个:
In my view controller I have this:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
我的Info.plist文件包含:
and my Info.plist file has this:
问题在于,当我将应用程序构建到iPod时,应用程序不会颠倒过来。 iPad将支持所有方向。
The problem is that when I build the app to my iPod, the app won't turn upside down. The iPad will support all Orientations.
我已经尝试一起删除 shouldAutorotateToInterfaceOrientation
,我试过这个代码:
I've tried removing the shouldAutorotateToInterfaceOrientation
all together and I've tried this code:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation = UIDeviceOrientationLandscapeLeft) && (interfaceOrientation = UIDeviceOrientationLandscapeRight) && (interfaceOrientation = UIDeviceOrientationPortraitUpsideDown) && (interfaceOrientation = UIDeviceOrientationPortrait);
}
但由于某种原因,颠倒只是行不通!还有其他解决方案吗?
But for some reason, the upside down just won't work! Are there any other solutions for this?
编辑:使用Xcode 4.5 iOS6
想出来,iOS6 SDK使用 shouldAutorotate
所以这是我的新代码:
Figured it out, the iOS6 SDK uses shouldAutorotate
so here is my new code:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
-(BOOL)shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}