覆盖内部UIViewController方法,因为内部方法给我的错误 [英] Overriding internal UIViewController methods because an internal method is giving me bugs
问题描述
重写内部UIViewController方法有什么后果?
What are the consequences of overriding internal UIViewController methods?
[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]
我有些问题。它会将我的帧大小调整为我不希望 有时 的值。我甚至不知道它在哪里挑选新的框架的值(它接近的超级视图的大小,我添加它,但是关闭2px)。参考:此问题,我还需要一些帮助。
[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]
is giving me some problems. It resizes my frame to values I do not desire sometimes. I do not even know where it picks off the new frame's values (it is close to the size of the superview to where I am adding it, but is off by 2px). Reference: this question, which I also need some help with.
我尝试定义一个空的 - (void)viewDidMoveToWindow:(UIWindow *)window shouldAppearOrDisappear:(BOOL)flag
视图控制器。错误不见了。 >。
I tried defining an empty - (void)viewDidMoveToWindow:(UIWindow *)window shouldAppearOrDisappear:(BOOL)flag
method in my view controller. Bug is gone. >.<
有没有人知道如果覆盖 -viewDidMoveToWindow:shouldAppearOrDisappear:
可以吗?或者其他解决方法?
Does anyone know if overriding -viewDidMoveToWindow:shouldAppearOrDisappear:
is ok to do? Or some other workaround?
或者,有人知道什么时候和为什么 -viewDidMoveToWindow:shouldAppearOrDisappear:
Or, does anyone know when and why -viewDidMoveToWindow:shouldAppearOrDisappear:
likes to change my frame dimensions sometimes?
提前感谢。
推荐答案
对于你的问题的为什么部分;框架可以在两种情况下自动更改:
For the "why" part of your question; the frame can automatically change in two situations:
- 您的ViewController是视图控制器层次结构(导航或TabBar)的一部分。在这种情况下,您的父ViewControllers做他们愿意与您的视图框架。
- 您的视图允许自动调整大小和父视图更改大小。这里要注意的是,根视图的大小更改为适合屏幕,导致所有子视图自动调整大小。
要找到您的案例中的确切罪魁祸首,您可以在重写的 setFrame:
中设置断点。
To find the exact culprit in your case you could set a breakpoint in the overridden setFrame:
.
这篇关于覆盖内部UIViewController方法,因为内部方法给我的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!