iPhone:在 viewWillAppear 之前 viewDidLoad 之后调用了什

时间:2023-02-15
本文介绍了iPhone:在 viewWillAppear 之前 viewDidLoad 之后调用了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的行为真的很奇怪.我有一个内部带有滚动视图的视图,其中包含我的界面.

Really strange behaviour here. I've got a view with a scroll view inside, which contains my interface.

在我的 viewDidLoad 中,我将 scrollView 的框架设置为原点为 0,0.

In my viewDidLoad, I set the frame of my scrollView to have an origin of 0,0.

我在 viewDidLoad 的末尾记录了原点,它是 0.但是,在我的 viewWillAppear 开头,原点是 -20.有谁知道可以调用哪种方法来做到这一点?

I log the origin at the end of my viewDidLoad, and it's 0. However, at the start of my viewWillAppear, the origin is -20. Does anyone know what kind of method could get called that would do this?

提前致谢

推荐答案

如果您想知道它可能是什么,您可以尝试注册您的视图以进行键值观察,如下所述:http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html

If you want to find out what it could be, you can try registering your view for key value observing, as described here: http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html

您可以注册以侦听 frame 属性的更改,然后在 observe 方法中设置一个断点,当您的 origin 设置为奇怪的值时,它应该可以让您准确地看到堆栈跟踪的用途.

You can register to listen for changes to the frame property, and then set a breakpoint in the observe method which should let you see exactly what the stacktrace is for when your origin is set to the strange value.

这篇关于iPhone:在 viewWillAppear 之前 viewDidLoad 之后调用了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:iOS:自动布局导致 UIScrollView 不滚动 下一篇:ScrollView 内的 LazyVStack 中具有可变高度的内容导致

相关文章

最新文章