1. <tfoot id='4tvfc'></tfoot>
    • <bdo id='4tvfc'></bdo><ul id='4tvfc'></ul>
    <i id='4tvfc'><tr id='4tvfc'><dt id='4tvfc'><q id='4tvfc'><span id='4tvfc'><b id='4tvfc'><form id='4tvfc'><ins id='4tvfc'></ins><ul id='4tvfc'></ul><sub id='4tvfc'></sub></form><legend id='4tvfc'></legend><bdo id='4tvfc'><pre id='4tvfc'><center id='4tvfc'></center></pre></bdo></b><th id='4tvfc'></th></span></q></dt></tr></i><div id='4tvfc'><tfoot id='4tvfc'></tfoot><dl id='4tvfc'><fieldset id='4tvfc'></fieldset></dl></div>

    <small id='4tvfc'></small><noframes id='4tvfc'>

  2. <legend id='4tvfc'><style id='4tvfc'><dir id='4tvfc'><q id='4tvfc'></q></dir></style></legend>

      Xcode 8 UIButtons 约束未显示

      时间:2023-07-08

      <small id='K3uxE'></small><noframes id='K3uxE'>

          <bdo id='K3uxE'></bdo><ul id='K3uxE'></ul>
          <legend id='K3uxE'><style id='K3uxE'><dir id='K3uxE'><q id='K3uxE'></q></dir></style></legend>
                <tbody id='K3uxE'></tbody>
              <tfoot id='K3uxE'></tfoot>

                <i id='K3uxE'><tr id='K3uxE'><dt id='K3uxE'><q id='K3uxE'><span id='K3uxE'><b id='K3uxE'><form id='K3uxE'><ins id='K3uxE'></ins><ul id='K3uxE'></ul><sub id='K3uxE'></sub></form><legend id='K3uxE'></legend><bdo id='K3uxE'><pre id='K3uxE'><center id='K3uxE'></center></pre></bdo></b><th id='K3uxE'></th></span></q></dt></tr></i><div id='K3uxE'><tfoot id='K3uxE'></tfoot><dl id='K3uxE'><fieldset id='K3uxE'></fieldset></dl></div>
                本文介绍了Xcode 8 UIButtons 约束未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                过去一切都很好,直到昨天我将 Xcode 更新到版本 8.

                Everything used to work great until yesterday I updated Xcode to version 8.

                如果我不使用任何约束,我可以看到按钮,但是当我对按钮应用约束时,它们会消失,无论约束是什么或多少(高度、垂直间距、尾随等...)我申请了.

                If I don't use any constraints, I can see the buttons but when I apply constraint(s) to the buttons they disappear, no matter what or how many constraints (height, vertical spacing, trailing etc...) I apply.

                当我点击按钮时,它们表现正常(事件总是被发送,所以我假设它们实际上位于那里(?)).我尝试更改文本颜色、背景颜色(甚至添加新的 UIButton),但没有成功.我看不到按钮.当我更改 Centered View 的背景颜色时,我可以在应用程序上看到此更改.最奇怪的部分是当我在 Xcode 上单击 Debug View Hierarchy 以查看发生了什么时,那里的一切看起来都很好;我可以看到所有按钮都按预期定位.

                When I tap buttons, they act normal (events are always sent so I assume they are actually located there(?)). I tried changing text color, background color, (even adding a new UIButton) but ended with no luck. I can't see the buttons. When I change the background color of Centered View I can see this change on the app. The weirdest part is when I click Debug View Hierarchy on Xcode to see what is going on, everything looks fine there; I can see all buttons located as I expect.

                在 iPhone 5 (iOS 9.3.5) 和 iPhone 6 (iOS 10) 上测试应用程序.

                Testing the app both on iPhone 5 (iOS 9.3.5) and iPhone 6 (iOS 10).

                我正在使用 Swift 2.3、iOS 10 和 Xcode 8.

                I am using Swift 2.3, iOS 10 and Xcode 8.

                这是 Xcode 8 上的错误吗?如何解决这个问题?

                Is this a bug on Xcode 8? How to resolve this issue?

                更新:

                我刚刚意识到 UILabel 和 UIImageView 也会出现同样的约束问题.它们在没有约束的情况下看起来很好,但是当我添加任何约束时它们就会消失.

                I just realised same constraint problem occurs on UILabel and UIImageView too. They look fine without constraint but when I add any constraint they disappear.

                推荐答案

                我错过了将 UIButton 类设置为我的自定义类的要点.我检查了我的自定义类,发现我在 awakeFromNib() 方法上设置了圆角半径.我在设置圆角半径之前调用了 layoutIfNeeded(),这是我的解决方案.

                I was missing the point of setting UIButton class to my custom class. I checked my custom class and have seen that I set corner radius on awakeFromNib() method. I called layoutIfNeeded() before I set corner radius which was the solution in my case.

                这篇关于Xcode 8 UIButtons 约束未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:具有按住动作和释放动作的 UIButton 下一篇:如何在 Swift 中为多个按钮使用一个 IBAction?

                相关文章

                  <bdo id='i1Uv1'></bdo><ul id='i1Uv1'></ul>
                <i id='i1Uv1'><tr id='i1Uv1'><dt id='i1Uv1'><q id='i1Uv1'><span id='i1Uv1'><b id='i1Uv1'><form id='i1Uv1'><ins id='i1Uv1'></ins><ul id='i1Uv1'></ul><sub id='i1Uv1'></sub></form><legend id='i1Uv1'></legend><bdo id='i1Uv1'><pre id='i1Uv1'><center id='i1Uv1'></center></pre></bdo></b><th id='i1Uv1'></th></span></q></dt></tr></i><div id='i1Uv1'><tfoot id='i1Uv1'></tfoot><dl id='i1Uv1'><fieldset id='i1Uv1'></fieldset></dl></div>

                    <tfoot id='i1Uv1'></tfoot>
                  1. <small id='i1Uv1'></small><noframes id='i1Uv1'>

                  2. <legend id='i1Uv1'><style id='i1Uv1'><dir id='i1Uv1'><q id='i1Uv1'></q></dir></style></legend>