viewDidLoad gets called, viewWillAppear does not get called, view does not appear on screen(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.
然后就变得奇怪了:
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 没有被调用,视图没有出现在屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:viewDidLoad 被调用,viewWillAppear 没有被调用,视图没有出现在屏幕上


- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 拆分 Drawable 2022-01-01