gpt4 book ai didi

iphone - 按钮文本未显示且 xcode 崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:10:36 26 4
gpt4 key购买 nike

我刚刚开始学习 IOS 开发。我花了几天时间试图解决这个问题,但我一无所获。希望有人能提供帮助。

我当时正在为 iPhone 开发一个计算器应用程序(只是为了练习)。我创建了一个按钮网格,但是当我开始创建最后一行时,xCode 在我创建或移动每个按钮后一直崩溃。我最终创建了布局,但是当我运行该应用程序时,底行的任何按钮都没有显示按钮文本(在 IOS 模拟器或我的 iPhone 上):

             +----+ +----+ +----+ +----+ +----+
| 7 | | 8 | | 9 | | + | | - |
| | | | | | | | | |
+----+ +----+ +----+ +----+ +----+

+----+ +----+ +----+ +----+ +----+
| 4 | | 5 | | 6 | | / | | * |
| | | | | | | | | |
+----+ +----+ +----+ +----+ +----+

+----+ +----+ +----+ +----+ +----+
| 1 | | 2 | | 3 | | | | AC |
| | | | | | | | | |
+----+ +----+ +----+ | | +----+
| = |
+----+ +----+ +----+ | | +----+
| | | | | | | | | |
| | | | | | | | | |
+----+ +----+ +----+ +----+ +----+

如果我将按钮从底部一行一个移动到顶部,文本会显示在它们上面,但仍然不在底部一行:

                    +----+ +----+        +----+
| . | | +- | | C |
| | | | | |
+----+ +----+ +----+

+----+ +----+ +----+ +----+ +----+
| 7 | | 8 | | 9 | | + | | - |
| | | | | | | | | |
+----+ +----+ +----+ +----+ +----+

+----+ +----+ +----+ +----+ +----+
| 4 | | 5 | | 6 | | / | | * |
| | | | | | | | | |
+----+ +----+ +----+ +----+ +----+

+----+ +----+ +----+ +----+ +----+
| 1 | | 2 | | 3 | | | | AC |
| | | | | | | | | |
+----+ +----+ +----+ | | +----+
| = |
+----+ | |
| | | |
| | | |
+----+ +----+

然后,当我将最后一个按钮移到顶部时,新的底部行停止显示文本:

             +----+ +----+ +----+        +----+
| 0 | | . | | +- | | C |
| | | | | | | |
+----+ +----+ +----+ +----+

+----+ +----+ +----+ +----+ +----+
| 7 | | 8 | | 9 | | + | | - |
| | | | | | | | | |
+----+ +----+ +----+ +----+ +----+

+----+ +----+ +----+ +----+ +----+
| 4 | | 5 | | 6 | | / | | * |
| | | | | | | | | |
+----+ +----+ +----+ +----+ +----+

+----+ +----+ +----+ +----+ +----+
| 1 | | 2 | | 3 | | | | AC |
| | | | | | | | | |
+----+ +----+ +----+ | | +----+
| |
| |
| |
| |
+----+

然后我向上移动等号按钮,新的底行无法显示文本:

                                  |    |
| |
+----+ +----+ +----+ | = | +----+
| 0 | | . | | +- | | | | C |
| | | | | | | | | |
+----+ +----+ +----+ +----+ +----+

+----+ +----+ +----+ +----+ +----+
| 7 | | 8 | | 9 | | + | | - |
| | | | | | | | | |
+----+ +----+ +----+ +----+ +----+

+----+ +----+ +----+ +----+ +----+
| 4 | | 5 | | 6 | | / | | * |
| | | | | | | | | |
+----+ +----+ +----+ +----+ +----+

+----+ +----+ +----+ +----+
| | | | | | | |
| | | | | | | |
+----+ +----+ +----+ +----+

这真是令人沮丧!我在一个新的应用程序中再次开始得到同样的东西,总是没有显示的最低对齐行。如果我切换到 3.5" View ,问题仍然存在。我尝试进一步间隔按钮,尝试更改所有文本参数,更改 View 以禁用自动调整 subview 并将模式从缩放更改为适合,但这仍在发生.我找不到任何其他描述此问题的帖子,这看起来很奇怪,因为它很容易重新创建。请帮助。

最佳答案

我建议仅在非常特殊的情况下才使用 iOS 6 的新自动布局选项。我已经非常深入地测试了这个选项并发现了很多错误,例如:

  • 在控制台中出现指示 apple bug 的消息
  • 它会显着减慢您的用户界面
  • 布局约束突然消失
  • 应用有时会崩溃并显示未记录的错误消息

目前使用自动布局非常令人沮丧。我没有使用自动布局,而是使用了

- (void)viewDidLayoutSubviews {}

以编程方式调整我的 UI,这更加容易和快速(在开发和运行时)。

关于iphone - 按钮文本未显示且 xcode 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14304048/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com