問題描述
這里的行為真的很奇怪.我有一個內部帶有滾動視圖的視圖,其中包含我的界面.
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模板網!