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

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

问题描述

更新

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

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.

还有其他想法吗?

原始问题

我被难住了.我正在重构一些代码并且遇到了一些奇怪的行为......

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

我在没有 nib 的情况下初始化 viewController A 并以编程方式设置视图.

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

控制器 A 中的 viewDidLoad 被调用.

viewDidLoad in controller A gets called.

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

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

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

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

控制器 B 的 viewDidload 被调用.

viewDidload of controller B gets called.

然后就变得奇怪了:

  1. viewWillAppear 和 viewDidAppearviewController B 从不得到调用.

viewControllerB.view 从不它在屏幕上.

viewControllerB.view never makes it on screen.

错误.

<小时>

我检查的内容:


Things I checked:

viewControllerBs Nib 的名称是正确的.

The name of the viewControllerBs Nib is correct.

viewControllerB 的视图出口连接到一个视图.

The view outlet of viewControllerB is connected to a view.

viewControllerB 和它的视图都是非零的.

viewControllerB and its view both are non-nil.

最重要的是,SDK [redacted] beta 5 中一切正常!

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

有什么想法吗?这一定是件很傻的事..

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

推荐答案

结案:

我永远找不到解决方案,但从那时起,SDK 3.0 成为标准,这一点已变得毫无意义.该代码在当前版本的 SDK 中可以正常工作.

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天全站免登陆