xcode 纵向仅适用于 iPad?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2721710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Portrait orientation only for iPad?
提问by NextRev
According to apple my application has to be able to run in both portrait modes. How do I accomplish this with shouldAutorotateToInterfaceOrientation??
根据苹果的说法,我的应用程序必须能够在两种纵向模式下运行。我如何使用 shouldAutorotateToInterfaceOrientation 完成此操作?
回答by kennytm
Just return YES no matter what the interface orientation is. This will allow the system autorotate to the upside-down orientation.
无论界面方向如何,只需返回 YES 即可。这将允许系统自动旋转到倒置方向。
If you don't want to support the landscape orientations, then return:
如果您不想支持横向,则返回:
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
回答by progrmr
This code allows any orientation except landscape:
此代码允许除横向外的任何方向:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
return (orientation != UIDeviceOrientationLandscapeLeft) &&
(orientation != UIDeviceOrientationLandscapeRight);
}
回答by Devaski
Submitted app was rejected for the above reason. App used only portrait(Home Button Down) orientation.
由于上述原因,提交的应用程序被拒绝。应用程序仅使用纵向(主页按钮向下)方向。
" app does not comply with the Apple iOS Human Interface Guidelines, as required by the App Store Review Guidelines.
" 应用程序不符合 App Store 指南要求的 Apple iOS 人机界面指南。
Specifically, app only supported the bottom-up variant of the portrait orientation, but not the top-up variant.
具体来说,app 只支持自下而上的纵向变体,不支持自上而上的变体。
While supporting both variants of both orientations, each with unique launch images, provides the best user experience and is recommended, we understand there are certain applications that must run in the portrait orientation only. In this case, it would be appropriate to support both variants of that orientation in your application, e.g., Home button up and down."
虽然支持两种方向的两种变体,每个变体都有独特的启动图像,提供最佳用户体验并被推荐,但我们了解某些应用程序必须仅以纵向运行。在这种情况下,在您的应用程序中支持该方向的两种变体是合适的,例如,主页按钮向上和向下。”
To solve. 1)
来解决。1)
`- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
2) Open info.plist add a new string UILaunchImageFile & insert value as Default-Portrait.png
2) 打开 info.plist 添加一个新字符串 UILaunchImageFile & insert value as Default-Portrait.png
3) Change Default.png to Default-Portrait.png & Duplicate the file to rename Default-PortraitUpsideDown.png(Rotate this one with 180 degree)
3) 将 Default.png 更改为 Default-Portrait.png & 复制文件以重命名 Default-PortraitUpsideDown.png(将此文件旋转 180 度)
This enables up & down portrait with respective launch images.
这可以启用带有相应启动图像的上下肖像。
make sure you use UIInterfaceOrientationIsPortrait(interfaceOrientation) in all view-controllers inside the app, if required so . also do a clean before run.
如果需要,请确保在应用程序内的所有视图控制器中使用 UIInterfaceOrientationIsPortrait(interfaceOrientation)。运行前也做一次清洁。
回答by grogers
Use this.
用这个。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}