Xcode 没有显示我的按钮、标签、文本字段和视图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30797682/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:16:26  来源:igfitidea点击:

Xcode is not showing my buttons, labels, textfields, and views

iosiphonexcodeswift

提问by idelara

Xcode is not showing all the buttons, textfields, etc. I have in my storyboard. As you can see in the image below, somehow all my elements are appearing with a "watermark" in the storyboard element inspector on the left. Why is it doing this? How can I fix it? It is driving me crazy because I cannot see where my elements are when I try and add some more...

Xcode 没有显示我的故事板中的所有按钮、文本字段等。正如您在下图中所看到的,不知何故,我的所有元素都在左侧的故事板元素检查器中出现了“水印”。为什么要这样做?我该如何解决?这让我发疯了,因为当我尝试添加更多元素时,我看不到我的元素在哪里......

enter image description hereenter image description here

在此处输入图片说明在此处输入图片说明

How can I solve this and why is Xcode so buggy anyways?

我该如何解决这个问题,以及为什么 Xcode 如此有问题?

采纳答案by Ewan Mellor

You have a size class enabled (note the blue bar across the center-bottomish). My guess is that all those views are missing in that size class. Click the bar, turn it back to Any x Any.

您启用了尺寸等级(注意中间底部的蓝色条)。我的猜测是该尺寸等级中缺少所有这些视图。单击该栏,将其转回 Any x Any。

回答by Shachar

I had a similar problem, some of my IBOutlets (labels) were showing on the Storyboard, I had no AutoLayout warnings/errors and everything seemed fine but yet some of the outlets were not showing on the Simulator. Things got even more complicated when I noticed that SOMETIMES the outlets DID show.. strange..

我有一个类似的问题,我的一些 IBOutlets(标签)显示在 Storyboard 上,我没有 AutoLayout 警告/错误,一切似乎都很好,但有些插座没有显示在模拟器上。当我注意到有时网点确实显示..奇怪..时,事情变得更加复杂。

I ended up wrapping the call to show the view controller in a GCD method like this (swift code):

我最终将调用包装起来以在这样的 GCD 方法中显示视图控制器(swift 代码):

dispatch_async(dispatch_get_main_queue()) {
        [unowned self] in
        let vc = self.pages[0]
        self.setViewControllers([vc], direction: .Forward, animated: false, completion: nil)
    }

And that solved it..

这解决了它..