简体   繁体   English

为什么我的App在iOS Simulator中总是向右移动?

[英]Why is my App always shifted to the right in the iOS Simulator?

I am building a simple iOS app using Storyboards. 我正在使用Storyboards构建一个简单的iOS应用程序。 Currently running Xcode 7.2.1. 当前正在运行Xcode 7.2.1。 I have previously built one using .XIB files and never had an issue with layouts on devices. 我以前使用.XIB文件构建了一个文件,但从未在设备上出现布局问题。

I have a UIViewController that has a UINavigationBar and Bar Button Item. 我有一个具有UINavigationBar和Bar Button Item的UIViewController。 When I run the app in the simulator, everything looks shifted to the right and partly off screen. 当我在模拟器中运行该应用程序时,所有内容看起来都移到了右侧,部分不在屏幕上。 The title should be shown in the centre. 标题应显示在中间。 I am simulating using iPhone 6 and everything in Simulated Metrics are set to Inferred. 我正在使用iPhone 6进行模拟,“模拟量度”中的所有内容均设置为“推断”。 Could someone help me understand, am I missing a step? 有人可以帮我理解吗,我错过了一步吗?

在此输入图像描述

在模拟器中查看

The views are shifted because you didn't set the auto layout constraints. 由于未设置自动布局约束,因此视图发生了变化。 To fix this, add missing constraints . 要解决此问题,请添加缺少的约束

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

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