viewDidLoad被调用,viewWillAppear没有被调用,视图不会出现在屏幕上 [英] viewDidLoad gets called, viewWillAppear does not get called, view does not appear on screen

查看:164
本文介绍了viewDidLoad被调用,viewWillAppear没有被调用,视图不会出现在屏幕上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新



已经提到viewWillAppear和viewDidAppear不会根据文档调用。
然而,我没有在这些方法中执行初始化,也没有添加UI元素到视图中。



我只是使用它们来放置断点来尝试调试



其他想法?






原始问题



我被骗了。我重构了一些代码,并遇到一些奇怪的行为....



我初始化viewController A没有一个nib,并以编程方式设置视图。

$



在viewController A的viewDidLoad中,我从一个nib初始化viewController B.



我添加viewControllerB.view作为viewControllerA.view的子视图



viewDidload控制器B被调用。






然后变得奇怪:


  1. viewWillAppear和viewDidAppear
    viewController B 从不获取
    调用。


  2. viewControllerB.view


  3. 没有错误。







我检查的内容:



viewControllerBs Nib的名称是正确的。



viewControllerB的视图输出连接到视图。



viewControllerB














$ b b $ b

有什么想法吗?

解决方案

关闭此事:



我永远找不到一个解决方案,但从那时起,SDK 3.0是标准,点已经变得模糊。该代码在SDK的当前版本中正常工作。


Update

It has been mentioned that viewWillAppear and viewDidAppear do not get called per the docs. However, I perform no initialization within these methods and no adding UI elements to the view.

I was just using them to place break points to try to debug this.

Any other ideas?


Original Question

I'm stumped. I'm refactoring some code and have come across some strange behavior....

I initialize viewController A without a nib and set the view programmatically.

viewDidLoad in controller A gets called.

Inside viewDidLoad of viewController A, I initialize viewController B from a nib.

I add viewControllerB.view as a subview of viewControllerA.view

viewDidload of controller B gets called.


Then it gets weird:

  1. viewWillAppear and viewDidAppear of viewController B never get called.

  2. viewControllerB.view never makes it on screen.

  3. No errors.


Things I checked:

The name of the viewControllerBs Nib is correct.

The view outlet of viewControllerB is connected to a view.

viewControllerB and its view both are non-nil.

And to top it off, everything works great in SDK [redacted] beta 5!

Any ideas? It's got to be something silly..

解决方案

To close the matter:

I could never find a solution, but since then SDK 3.0 is the standard and the point has become moot. The code does work correctly in current versions of the SDK.

这篇关于viewDidLoad被调用,viewWillAppear没有被调用,视图不会出现在屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆