gpt4 book ai didi

ios - 为什么更改 UILabel 文本会触发 viewDidLayoutSubviews 事件?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:19:28 24 4
gpt4 key购买 nike

<分区>

我的 ViewController 中触发了很多 viewDidLayoutSubviews 事件。最终我缩小到触发事件的单行代码:

self.debugLabel.text = [NSString stringWithFormat:@"%@ - %@", key, [@(tag) stringValue]];

它是添加到 ViewController 的 self.view 的 subview 中的 UILabel。为什么更改 UILabel 的文本会导致边界发生变化?在 viewDidLayoutSubviews 文档中:

When the bounds change for a view controller's view, the view adjusts the positions of its subviews and then the system calls this method.

附注我确定 debugLabel 字体大小足够小以适合其框架。

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