简体   繁体   English

iOS模拟器屏幕尺寸

[英]iOS simulator screen size

It is just 2days to start iOS programming. 开始iOS编程只有2天。

So I'm very beginner in this area. 所以我是这个领域的初学者。

在此处输入图片说明 <--This image is in iOS simulator. <-此图像在iOS模拟器中。 As you see right part is cropped. 如您所见,右侧部分被裁剪。

在此处输入图片说明 <--This image is original UI. <-此图像是原始UI。

I don't know why some parts have gone. 我不知道为什么有些零件不见了。

I am using MacBook Pro 2011 with Yosemite OS and brand-new XCode. 我正在将MacBook Pro 2011与Yosemite OS和全新的XCode结合使用。

I tried cmd+1, cmd+2, cmd+3. 我尝试了cmd + 1,cmd + 2,cmd + 3。

Please help me. 请帮我。

Thank you in advance. 先感谢您。

转到文件检查器,然后取消选中“使用尺寸类别”选项,这是由于新引入的尺寸类别功能可支持ios 8中的所有设备

The new user interface works with all sizes of devices at once. 新的用户界面可同时与所有大小的设备一起使用。 The default size is 600x600 as you are seeing. 如您所见,默认大小为600x600。 When you simulate, is uses autolayout and constraints to arrange objects for the desired screen, aka an iPhone. 当您进行仿真时,是使用自动布局和约束来为所需屏幕(也称为iPhone)排列对象。 If you want to place the label in the center of the screen, Ctrl+drag from the label to the background, release mouse and buttons and the constraints options will appear. 如果要将标签放置在屏幕的中央,请按住Ctrl键并从标签拖动到背景,释放鼠标和按钮,然后将显示约束选项。 Click Center Horizontally in Container and Center Vertically in Container. 单击“在容器中水平居中”和“在容器中垂直居中”。 Run again. 再次运行。 It will be centered. 它将居中。

Best regards 最好的祝福

选择您的视图控制器并找到尺寸检查器,将“固定”更改为“自由格式”并提供所需的任何尺寸

I had a closely related question, and Mehul Thakkar's answer helped me to get where I needed to be, but I'm adding a new answer to flesh out both the question and answer a bit. 我有一个密切相关的问题,Mehul Thakkar的答案帮助我到达了需要去的地方,但我添加了一个新答案,以充实问题和答案。

I was working on an iPhone app for iOS 8 that was shrinking the interface on larger screens to the size of the iPhone 4s. 我正在为iOS 8开发iPhone应用程序,该应用程序将大屏幕上的界面缩小到iPhone 4s的大小。 I don't use storyboards or Interface Builder nib/xib files at all, and do everything programmatically; 我根本不使用情节提要或Interface Builder nib / xib文件,而是以编程方式进行所有操作。 for iOS 7 and earlier, I didn't bother making an explicit launch screen as my UI was simple enough that it loaded very quickly and a launch screen wasn't necessary. 对于iOS 7和更早的版本,我无需费心制作一个明确的启动屏幕,因为我的UI非常简单,可以非常快速地加载并且不需要启动屏幕。

Anyway, after finding this page and poking around a bit, it appears that creating a launch screen storyboard or nib/xib is now necessary on iOS 8, if you want your application to run at the correct size? 无论如何,找到该页面并稍作浏览之后,看来如果要使应用程序以正确的大小运行,则必须在iOS 8上创建启动屏幕故事板或nib / xib。 (At least, I couldn't find any other way to coerce Xcode to do it in the project settings or whatnot.) (至少,我找不到在项目设置中强制Xcode强制执行此操作的其他方法。)

To do this, I created a new launch screen .xib file, unchecked "Use Size Classes" in the "Interface Builder Document" section of the File Inspector of that .xib file, and set the "Launch Screen File" under the General tab of my target settings to use that .xib. 为此,我创建了一个新的启动屏幕.xib文件,在该.xib文件的“文件检查器”的“接口生成器文档”部分中未选中“使用大小类”,然后在“常规”选项卡下设置“启动屏幕文件”使用该.xib的目标设置 After that, the app ran at full screen size again. 之后,该应用再次以全屏尺寸运行。

This works for me and I guess I don't mind putting in a few minutes to turn the .xib file into a proper splash screen, but I'd be interested in hearing if there are other/better ways of making things work in iOS 8 and beyond, for those of us who hate our lovely code being tainted by the presence of those nasty storyboards/nibs/xibs... 这对我有用,我想我不介意花几分钟将.xib文件转换为适当的启动屏幕,但是我想听听是否有其他/更好的方法可以使iOS正常工作8岁及以上,对于那些讨厌我们的可爱代码的人来说,这些讨厌的故事板/笔尖/笔尖的存在给我们带来了污染...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM