Apple关于iPad应用需要支持设备方向的要求
2010-12-19 07:19:18 来源:WEB开发网Technical Q&A QA1689
Supporting orientations for iPad apps
Q: Which orientations should my iPad application support?
A: It is strongly recommended that your application support all orientations. This includes portrait, portrait upside-down, landscape left and landscape right.
If it is essential that your application run in only one orientation (for instance, portrait only), then you should:
Launch in your supported orientation, regardless of the current device orientation.
Avoid displaying any UI element that tells people to rotate the device.
Support both variants of an orientation.
IMPORTANT: You should always make your application support both variants of an orientation. More specifically, if your application supports portrait, then it should support both UIInterfaceOrientationPortrait and UIInterfaceOrientationPortraitUpsideDown; if your application supports landscape, then it should support both UIInterfaceOrientationLandscapeLeft and UIInterfaceOrientationLandscapeRight.
When you are writing your application, consider using UIKit's interface orientation macros. In your UIViewController class, you should implement
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation to return:
UIInterfaceOrientationIsPortrait(interfaceOrientation) - if you support only portrait.
UIInterfaceOrientationIsLandscape(interfaceOrientation) - if you support only landscape.
Listing 1: Using an orientation macro in a portrait-only application
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsPortrait(interfaceOrientation);}Note: If you are using UIDeviceOrientation, note that the iPad simulator does not support the constants UIDeviceOrientationFaceUp,UIDeviceOrientationFaceDown or UIDeviceOrientationUnknown.
更多精彩
赞助商链接