构建和模拟应用程序时的 Xcode 7 白屏
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33940710/
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
Xcode 7 white screen when app is built and simulated
提问by peterbonar
When I hit the run button for my app,
当我点击应用程序的运行按钮时,
the simulator just shows a white screen
模拟器只显示白屏
however there should be a button that says "Hello World". Also, for the label,
但是应该有一个按钮,上面写着“Hello World”。此外,对于标签,
an error message saying "Position is ambiguous for "Hello World"
一条错误消息说“位置对于“Hello World”不明确
Any ideas what is going wrong here?
任何想法这里出了什么问题?
回答by Aaron B. Rosa
I think you need to check the info.plist file, and make sure that you are pointing to the right value for the view you are trying to see in the simulator (ie. LaunchScreen.storyboard, or main.storyboard). I had the same issues, and made this change to solve it.
我认为您需要检查 info.plist 文件,并确保您指向您尝试在模拟器中查看的视图的正确值(即 LaunchScreen.storyboard 或 main.storyboard)。我遇到了同样的问题,并进行了此更改以解决它。
回答by GlennRay
Open up HelloWorldViewController.xib by clicking on it. Select the Hello World button. At the bottom right of the panel, you'll see a short row of icons. Click the one highlighted below in red. Check off the Horizontally in Container
and Vertically in Container
items. The Add Constraints
button at the bottom should then become active -- click it to add those two constraints. Do the same for the label. Now run your app.
单击它打开 HelloWorldViewController.xib。选择 Hello World 按钮。在面板的右下角,您会看到一小排图标。单击下面以红色突出显示的那个。勾选Horizontally in Container
和Vertically in Container
项目。Add Constraints
然后底部的按钮应变为活动状态——单击它以添加这两个约束。对标签执行相同操作。现在运行您的应用程序。
回答by Abhishek Bedi
Please check if the view in the storyboard is connected to the file owner.
You may give a background color to the view just to check if the same is reflected on launch. If yes, you may add vertical and horizontal center align constraints to your label.
If no, then your view controller is not yet on the screen.
Please post your code.
请检查故事板中的视图是否已连接到文件所有者。您可以为视图提供背景颜色,以检查启动时是否反映相同。如果是,您可以向标签添加垂直和水平中心对齐约束。
如果不是,那么您的视图控制器还没有出现在屏幕上。
请发布您的代码。
回答by anomeric
You need to add constraints to your hello world label. You can add constraints to a view by selecting it and pressing on one of the constraint buttons on the bottom right side of the view editor. Currently, it sounds like your label is displaying off screen.
您需要为 hello world 标签添加约束。您可以通过选择视图并按下视图编辑器右下方的约束按钮之一来向视图添加约束。目前,听起来您的标签显示在屏幕外。
回答by Daniel T.
The problem is that the position of the views are ambiguous and they are "displaying" off screen. Check out this link https://teamtreehouse.com/library/implementing-designs-for-iphone/implementing-custom-login-and-sign-up-screens/adding-background-images-and-positioning-views
问题是视图的位置不明确,它们在屏幕外“显示”。查看此链接https://teamtreehouse.com/library/implementing-designs-for-iphone/implementing-custom-login-and-sign-up-screens/adding-background-images-and-positioning-views
回答by Donato
I am surprised none of the answers addressed an obvious issue as to why this might be happening. I just purchased a MacBook Air, the small 33 inch display.
我很惊讶没有一个答案解决了为什么会发生这种情况的明显问题。我刚刚购买了 MacBook Air,它是 33 英寸的小显示器。
When you run the emulator, it displays at 50 percent. On the Air, 50 percent is zoomed to close. Go to window > scale > 33% and you will see your content.
当您运行模拟器时,它显示为 50%。在空中,50% 被放大到关闭。转到窗口 > 缩放 > 33%,您将看到您的内容。