开发者

Overriding internal UIViewController methods because an internal method is giving me bugs

What are the consequences of overriding internal UIViewController methods?

[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.

I tried defining an empty - (void)viewDidMoveToWindow:(UIWindow *)window shouldAppearOrDisappear:(BOOL)flag method in my view controller. Bug is gone. >.<

Does anyone know if overriding -viewDidMoveToWindow:shouldA开发者_Python百科ppearOrDisappear: is ok to do? Or some other workaround?

Or, does anyone know when and why -viewDidMoveToWindow:shouldAppearOrDisappear: likes to change my frame dimensions sometimes?

Thanks in advance.


If you override that method you run the risk of getting rejected, it is undocumented. An approach that isn't against the rules is to override the setFrame: method of the view in the view controller though.

If you believe this is a bug, put together a minimal test case and submit it to http://bugreport.apple.com and potentially upload it somewhere that we can see exactly what is happening as well.


For the "why" part of your question; the frame can automatically change in two situations:

  1. Your ViewController is part of a view controller hierarchy (Navigation or TabBar). In this case your parent ViewControllers do as they please with your views frame.
  2. Your view allows autosizing and the parent view changes size. The thing to note here is that the size of the root view is changed to fit the screen, causing autosizing to happen for all subviews.

To find the exact culprit in your case you could set a breakpoint in the overridden setFrame:.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜