简体   繁体   English

应用程序在部署到iPhone 6s时会调整大小-Xcode

[英]App resizes on deployment to iphone 6s - xcode

I have a simple single screen app with two buttons that looks great on the story board on xcode. 我有一个简单的单屏幕应用程序,带有两个按钮,在xcode的故事板上看起来很棒。 As soon as I run the app on my iphone 6s, it resizes the screen and the buttons at the bottom disappear. 一旦在iphone 6s上运行该应用程序,它就会调整屏幕大小,底部的按钮会消失。 It looks like the resolution has changed and the app is not meant for an iphone 6s screen. 分辨率似乎已更改,并且该应用程序不适用于iPhone 6s屏幕。

I have already tried the following without any success: 我已经尝试了以下方法,但没有成功:

1) Enabled "Use Auto Layout" for my View controller in the File Inspector menu(under utilities) 1)在“文件检查器”菜单(在实用程序下)中为我的View控制器启用了“使用自动布局”

2) Set the deployment target to "10.3", Devices to "iPhone" and checked "portrait, landscape left and landscape right" for Device orientation under the General Settings. 2)将部署目标设置为“ 10.3”,将设备设置为“ iPhone”,并在“常规设置”下选中“纵向,横向和横向向右”。

Is there any other setting that I might have missed to check that is causing this scaling? 是否还有其他设置我可能会错过来检查导致此缩放的设置? I am using xcode 8.3 我正在使用xcode 8.3

Edit: I recieved some great feedback in the comments section, and learnt about adding constraints. 编辑:我在评论部分收到了一些很好的反馈,并了解了添加约束的知识。 I am here adding screenshots of what my app looks like before and after adding constraints: 我在这里添加添加约束前后我的应用程序外观的屏幕截图:

Here is my xcode storyboard (what I am looking to get on my iPhone 6s) 这是我的xcode故事板(我希望在iPhone 6s上安装)

在此处输入图片说明

And here is a screenshot of what I have on my phone (prior to constraining) 这是我手机上的屏幕快照(在约束之前)

在此处输入图片说明

I have tried constraining the view like so with no luck (same output on the phone): 我试过这样限制视图,但没有运气(电话上的输出相同):

在此处输入图片说明

Is there a specific set of constraints that will do the job here? 是否有一组特定的约束可以在这里完成工作?

Your screenshots show that you have not set your constraints. 屏幕快照显示您尚未设置约束。 The last screenshot shows that you have set some constraints on the root view. 最后一个屏幕截图显示您已经在根视图上设置了一些约束。 Like mentioned by Martin you need to have constraints for each object. 就像马丁提到的那样,您需要为每个对象设置约束。

To place the button correctly at the bottom of the view, you need to draw from your button to your view (holding the ctrl-key) and then select the bottom, leading and trailing constraints. 为了将按钮正确放置在视图的底部,需要从按钮绘制到视图(按住ctrl键),然后选择底部,前导和尾随约束。

I suggest to make a beginner tutorial in Autolayout with InterfaceBuilder. 我建议使用InterfaceBuilder在Autolayout中制作一个初学者教程。

Thank you for your great responses. 感谢您的好评。 Turns out the solution was a little different than just experimenting with constraints. 事实证明,该解决方案与仅试验约束条件有所不同。 It took me about 3 hours to figure this out, and I wanted to share the simple solution here in case someone else goes through the same thing in the future. 我花了大约3个小时来解决这个问题,我想在这里分享简单的解决方案,以防将来有人遇到同样的事情。

The problem was in the General section of the settings. 问题出在设置的“常规”部分。 Your Launch Screen File must reflect the MainStoryboard like so: 您的启动屏幕文件必须反映MainStoryboard,如下所示:

在此处输入图片说明

My Launch Screen File option was previously set to nothing which caused the problem. 我的启动屏幕文件选项以前未设置为导致问题的所有内容。 As soon as I changed it to the MainStoryboard, things look just fine. 一旦将其更改为MainStoryboard,一切就很好了。 Hope this helps someone! 希望这对某人有帮助!

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

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