Xcode6、iOS8 和 (void)layoutSubviews

2023-09-10移动开发问题
5

本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何在 UIImageView 上添加交互式 UILabel?
How to add interactive UILabels on top of a UIImageView?(如何在 UIImageView 上添加交互式 UILabel?)...
2024-04-15 移动开发问题
9

自动布局 UIImageView 与编程重新大小不遵循约束
Autolayout UIImageView with programatic re-size not following constraints(自动布局 UIImageView 与编程重新大小不遵循约束)...
2024-04-14 移动开发问题
6

如何获得自动布局来覆盖 UIImageView 的固有大小?
How can I get autolayout to override a UIImageView#39;s intrinsic size?(如何获得自动布局来覆盖 UIImageView 的固有大小?)...
2024-04-14 移动开发问题
16

WKWebView 和 NSURLProtocol 不起作用
WKWebView and NSURLProtocol not working(WKWebView 和 NSURLProtocol 不起作用)...
2023-10-23 移动开发问题
20

当用户点击下拉列表 HTML 选择标签时,ios8 iPad uiwebview 在显示弹出窗口时崩溃
ios8 iPad uiwebview crashes while displaying popover when user taps drop down list HTML select tag(当用户点击下拉列表 HTML 选择标签时,ios8 iPad uiwebview 在显示弹出窗口时崩溃)...
2023-10-23 移动开发问题
1

iOS 8 SDK:模态 UIWebView 和相机/图像选择器
iOS 8 SDK: modal UIWebView and camera/image picker(iOS 8 SDK:模态 UIWebView 和相机/图像选择器)...
2023-10-23 移动开发问题
0