xcode iphone 的屏幕分辨率是 320x460 还是 320x480?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11784767/
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
Is an iphones screen resolution 320x460, or 320x480?
提问by bmende
I'm so confused. I don't have a status bar, and I don't know how to make my scroll view's dimensions. Is it 320 x 480, or 320 x 460? Because when I drag it out onto storyboard and it fills the entire screen it says it is 320 x 460, but then when I add subviews to it they get positioned strangely and so that it's like the views are 20 pixels short or something.
我很困惑。我没有状态栏,也不知道如何设置滚动视图的尺寸。是 320 x 480 还是 320 x 460?因为当我把它拖到情节提要上并填满整个屏幕时,它说它是 320 x 460,但是当我向它添加子视图时,它们的位置很奇怪,所以它就像视图短 20 像素或其他东西。
EDIT: I'm just a little confused because when my status bar goes away, it doesn't re adjust the view size, it just makes the view 20 pix shorter, which doesn't really make sense, right? Shouldn't it make it 20 pix longer instead of just cutting off 20 pix?
编辑:我只是有点困惑,因为当我的状态栏消失时,它不会重新调整视图大小,它只会使视图缩短 20 像素,这真的没有意义,对吧?它不应该让它长 20 像素而不是仅仅切断 20 像素吗?
回答by Ryan Poolos
The iPhone screen is 320x480 definitely.
iPhone 屏幕肯定是 320x480。
The reason you're having an issue in storyboards is there are multiple places to tell it you don't have a status bar. You need to track down all of them (3?) and make sure it says no status bar.
您在故事板中遇到问题的原因是有多个地方可以告诉它您没有状态栏。您需要追踪所有这些(3?)并确保它没有显示状态栏。
The most common problem is that you have your status bar either on or inferred in one of your earlier viewControllers while you've exclusively set it to off in a nested viewController. This causes it not to have a status bar but show itself as 460 pixels high. as you can see in the image its clearly 20 pixels shorter. Thats because the segue is telling it that when its presented to present it "under" the status bar even though it doesn't have one itself. If I were to change the segue from a modal to push the problem goes away. Or if I set the first viewController to have no statusBar as well the problem goes away. Also note that Xcode can require a restart to properly update its graphical storyboard in some instances.
最常见的问题是,当您在嵌套的 viewController 中专门将状态栏设置为关闭时,您的状态栏要么在早期的 viewController 中打开,要么在其中推断出来。这会导致它没有状态栏,而是显示为 460 像素高。正如您在图像中看到的,它明显缩短了 20 个像素。那是因为 segue 告诉它,当它出现在状态栏“下方”时,即使它本身没有。如果我要从模态更改 segue 以推动问题消失。或者,如果我将第一个 viewController 设置为没有 statusBar,问题就会消失。另请注意,在某些情况下,Xcode 可能需要重新启动才能正确更新其图形故事板。
One More Thing
还有一件事
Also setting either in code or storyboards to hide the status bar isn't the same as setting the UIStatusBarHidden
to YES
in your .info file. If you left it to no while hiding it everywhere else your default.png will be clipped and show the status bar while loading then it will disappear once the app finishes launching. So be sure to hide it there as well for a consistent user experience.
此外,在代码或故事板中设置以隐藏状态栏UIStatusBarHidden
与YES
在 .info 文件中设置为不同。如果您将它隐藏在其他任何地方时将其保留为 no,则您的 default.png 将被剪切并在加载时显示状态栏,然后一旦应用程序完成启动它就会消失。所以一定要把它隐藏在那里,以获得一致的用户体验。
Code
代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[application setStatusBarHidden:YES];
}
回答by Oscar Gomez
it is 320 x 480, the 20 pixels you are seeing is the status bar, if you are planning on hiding the status bar and want to match the size in Interface Builder, you can go to IB to Simulated Metrics -> Status Bar and select None.
它是 320 x 480,你看到的 20 像素是状态栏,如果你打算隐藏状态栏并想在 Interface Builder 中匹配大小,你可以去 IB to Simulated Metrics -> Status Bar 并选择没有任何。
This will not affect the real size of the view in your view controller, though as it will resize itself to fit in the size even if you set the view to be 320 x 480, the view controller will resize itself to 320 x 460 if there is a status bar and 320 x 418 if there is also a navigation bar.
这不会影响视图控制器中视图的实际大小,尽管它会调整自身大小以适应大小,即使您将视图设置为 320 x 480,如果存在,视图控制器也会将自身调整为 320 x 460是状态栏,如果还有导航栏,则为 320 x 418。
回答by nico
I am a bit out of iPhone-programming, but this 20px should be the upper border, where you can see the carrier and strength etc.
我有点不懂 iPhone 编程,但是这个 20px 应该是上边框,在那里你可以看到载体和强度等。