[英]Why is iOS simulator displaying blank screen when I rotate device?
Getting through some introductory swift and playing with Xcode and I basically just have a page with some color squares, background color etc. Doesn't do anything. 快速入门并使用Xcode,我基本上只有一个带有一些颜色方块,背景颜色等的页面。什么都不做。 Problem is when I compile the code it will run in simulator just fine and show everything perfect, BUT when I rotate the device, everything disappears and it only gives me a blank white screen. 问题是,当我编译代码时,它将在模拟器中正常运行并显示一切完美,但是,当我旋转设备时,一切消失了,它只给了我空白的白色屏幕。 Rotating right or left does it. 向右或向左旋转即可。 The only view that shows it is the original upright view (for all iPhone devices that I tested on through the simulator). 唯一显示该视图的视图是原始的垂直视图(适用于我通过模拟器测试过的所有iPhone设备)。
Xcode 6.1.1 and iOS Simulator 8.1 are being used on my MacBook Air with OSX 10.9.5. Xcode 6.1.1和iOS Simulator 8.1正在OSX 10.9.5的MacBook Air上使用。
In the App general page, I have already checked under Deployment info that Landscape Right and Left are both checked on. 在“应用程序常规”页面中,我已经在“部署信息”下检查了“横向右移”和“左移”均已选中。 Storyboard is set on Any H and Any W. 情节提要设置在任何H和任何W上。
I'm not sure what I'm doing wrong and it has been pretty difficult searching since I'm still new to iOS development I'm not sure I'm using the right words or whatever because I can't find an answer. 我不确定自己在做什么错,而且由于我仍然不熟悉iOS开发,因此搜索一直很困难。我不确定我使用的是正确的字眼还是因为找不到答案。
Summary: 摘要:
App displays properly in iOS Simulator, Portrait View but no other views work and will display blank white screen instead. 应用程序可以在iOS模拟器中正常显示,“人像视图”,但没有其他视图可用,而是显示空白屏幕。
In order to see if your views are actually being drawn and just off screen as others have suggested capture the view hierarchy. 为了查看您的视图是否真正被绘制并且是否在屏幕上,其他人建议捕获视图层次结构。 Go to 'debug' in the menu, then in 'view debugging' click capture view hierarchy. 转到菜单中的“调试”,然后在“视图调试”中单击捕获视图层次结构。 This will pause your app and create a 3D representation of all view on your screen which you can move around by clicking and dragging. 这将暂停您的应用程序,并创建屏幕上所有视图的3D表示,您可以通过单击和拖动来移动它。
Are your views actually being drawn? 您的观点确实被绘制了吗? If yes are they drawing off screen? 如果是,他们是否正在退出屏幕? If yes then you need to fix your constraints. 如果是,那么您需要解决您的约束。
You don't have the correct auto-layout UIConstraint
s set in interface builder. 您没有在界面构建器中设置正确的自动布局UIConstraint
。 Check the document outline view in interface builder and ensure that you have appropriate constraints set on each view. 在界面构建器中检查文档大纲视图,并确保在每个视图上都设置了适当的约束。
Auto Layout issues occur when you create conflicting constraints, when you don't provide enough constraints , or when the final layout contains a set of constraints that are ambiguous. 当您创建冲突的约束, 没有提供足够的约束或最终的布局包含一组模糊的约束时,就会出现自动布局问题。
Check this Apple documentation out, it will show you step by step how to resolve your (common) issue. 请查阅此Apple 文档 ,它将逐步向您展示如何解决(常见)问题。
It sounds like you haven't set your constraints appropriately. 听起来您没有适当设置约束。 Try setting the top and leading constraints for each of your views to something less than 320 (should cover all device sizes). 尝试将每个视图的顶部和顶部约束设置为小于320(应涵盖所有设备尺寸)。 Fix your warnings, then try again. 解决您的警告,然后重试。 I believe the views are simply off the screen. 我认为视图完全不在屏幕上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.