Xcode6、iOS8 和 (void)layoutSubviews

Xcode6, iOS8 and (void)layoutSubviews(Xcode6、iOS8 和 (void)layoutSubviews)

本文介绍了Xcode6、iOS8 和 (void)layoutSubviews的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有自定义的 UILabel,它在 iOS6 和 iOS7 上运行良好.但是在 iOS8 上,这个标签的 (void)layoutSubviews 方法永远不会被调用.我用 initWithFrame 创建了这个标签,所以应该调用这个方法 - 它在另一个 iOS 版本上被调用.iOS8 中的 autoLayout 系统会发生什么?

I have custom UILabel which works fine on iOS6 and iOS7. But on iOS8 this label's (void)layoutSubviews method never get called. I create this label with initWithFrame, so this method should be called - and it's called on another iOS versions. What happens with autoLayout system in iOS8?

推荐答案

我只想添加这个答案,因为问题标题可能会导致很多人在这里遇到类似的问题(比如我).

I just want to add this answer because the question title may lead a lot of ppl here with similar issues (like me).

iOS 8 到 8.0.2 LayoutSubviews 调用不可靠.它们可能永远不会被调用,或者(在我的情况下)被循环调用.

With iOS 8 to 8.0.2 LayoutSubviews calls are unreliable. They may not be called ever or (in my case) are called in a loop.

即使您不应该这样做,在 LayoutSubviews 中分配内容也是相当安全的,但是这种错误 (?!) 行为可能会导致难以追踪的错误.

Even though you should not do it, it was pretty safe to alloc stuff in LayoutSubviews, but with this buggy (?!) behaviour it can cause hard-to-trace bugs.

我不知道 8.1 是否解决了所有问题,但客户设备运行 8.1 并且他们现在确实运行 8.0.2 还需要一段时间

I don't know if 8.1 fixes all the issues but it will be some time until customer devices will run 8.1 and they do run 8.0.2 NOW

这篇关于Xcode6、iOS8 和 (void)layoutSubviews的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Xcode6、iOS8 和 (void)layoutSubviews

基础教程推荐