与界面生成器和模拟器相比,为什么 UILabel 换行符位于设备上的不同位置?

发布于 2024-12-23 11:42:33 字数 301 浏览 1 评论 0原文

最近,我在界面生成器中创建的几个多行 UILabels 遇到了一些问题。在界面生成器中,每个标签都足够大以容纳其包含的文本。同样,当我在模拟器中运行它时,每个标签都足够大。但是当我在我的设备上运行它时,一些黑魔法导致换行符发生在不同的位置,并且并非所有文本都可见。

我故意在 IB 中将有问题的标签设置得过大,这确实起到了作用,但我很好奇是什么导致了这些差异。有谁知道它可能是什么?

我通过 MonoTouch 使用 Xcode 4.2 中的界面生成器。手机是 3GS,运行 iOS 4.3.5,但我的模拟器似乎卡在 iOS 5 上(我猜这可能与此有关)。

I recently ran into a few problems with several multiline UILabels that I had created in interface builder. In interface builder, each label was large enough for the text it contained. Similarly, when I ran it in the simulator each label was large enough. But when I ran it on my device, some black magic caused the line breaks to occur at different places and not all of the text was visible.

I resorted to deliberately making the offending labels too big in IB, which did the trick, but I was left curious as to what was causing the differences. Does anyone have any idea what it might be?

I was using the interface builder in Xcode 4.2 through MonoTouch. The phone is a 3GS and runs iOS 4.3.5, but my simulator seems stuck on iOS 5 (which I guess might be something to do with it).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掌心的温暖 2024-12-30 11:42:33

看起来最可能的解释是不同版本的 iOS 使用略有不同的系统字体。 Interface Builder 和 iPhone 模拟器可能使用一种字体,但当我将其放在 iOS 4.3.5 手机上时,它使用另一种字体。我认为这很可能与操作系统有关,而不是与设备有关,因为我已经能够在运行 iOS 4.2 的 iPhone 4 上尝试它 - 行为与我的 3GS 上相同。

感谢 Krumelur 和 Mark Adams 的评论!

Looks like the most likely explanation is that the different versions of iOS use a slightly different System font. Interface Builder and the iPhone simulator were probably using one font, but when I put it on my iOS 4.3.5 phone it was using another. I think it is most likely to be something to do with the OS and not the device because I have since been able to try it on an iPhone 4 which was running iOS 4.2 - the behaviour was the same as on my 3GS.

Thanks to Krumelur and Mark Adams for the comments!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文