推送视图后 UINavigationController 显示黑屏 [英] UINavigationController shows black screen after pushing a view

查看:40
本文介绍了推送视图后 UINavigationController 显示黑屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有导航控制器和两个视图控制器(A"、B")的故事板应用程序.

I have a storyboard application with a navigation controller an two views controllers ('A', 'B').

在故事板文件中:Navigationcontroller 是初始的视图控制器.视图控制器A"作为根控制器连接到导航控制器.视图控制器B"在故事板中,但未连接到任何视图控制器.

In the Storyboard file: Navigationcontroller is the initial view controller. view controller 'A' is connected to the Navigationcontroller as rootcontroller. View controller 'B' is in storyboard but not connected to any view controller.

当我以编程方式尝试从视图控制器A"内部将视图控制器B"推送到导航控制器时:

when i programmatically try to push view controller 'B' onto the navigationcontroller from inside view controller 'A' with:

B *controllerB = [[B alloc] init];
[self.navigationController pushViewController:controllerB animated:YES];

我得到的只是过渡到黑屏.

all i get is a transition to a black screen.

我在运行时检查了视图控制器 A 中的 navigationController 属性,它不是 nil.我不会自己实例化 navigationController,我让故事板来完成工作(也许这就是问题所在).但我认为应该可以手动"将视图控制器推送到故事板创建的导航控制器.

i checked the navigationController property in view controller A at runtime and it´s not nil. I do not instantiate the navigationController by myself, I let storyboard do the work (maybe that´s the problem). But I think it should be possible to "manually" push view controller to a navigation controller created by storyboard.

当我将 segue 从按钮连接到故事板中的B"时,一切正常.仅以编程方式它不起作用,仅在导航控制器内显示黑屏.

When I connect a segue from a button to 'B' in storyboard everything works fine. Only programmatically it does not work, only shows a black screen inside the navigationcontroller.

也许有人可以帮助我解决这个问题.

Maybe someone could help me with this issue.

推荐答案

接受的答案对我不起作用.我已经在使用 instantiateViewControllerWithIdentifier 导航到不同故事板中的视图控制器.我正在使用 xcode7.2 和 Swift.

The accepted answer didn't work for me. I was already using instantiateViewControllerWithIdentifier to navigate to view controller in different storyboard. I am using xcode7.2 and Swift.

我从 storyboard1 导航,一些视图控制器的按钮动作.目标是 Storyboard2 的初始导航控制器.
我还是黑屏.

I am navigating from storyboard1, some view controller's button action. Destination is to initial Navigation controller of Storyboard2.
Still I get black screen.

问题是通过 show 链接到第一个视图控制器的 storyboard2 的导航控制器.

The problem was storyboard2's Navigation controller linked to 1st view controller was linked via show.

解决方案:
删除导航控制器和第一个视图控制器之间的链接.现在使用 root view controller 链接它.(Ctrl+单击导航控制器并将其拖到视图控制器并选择根视图控制器"选项)

Solution:
Delete the link between Nav controller and 1st view controller. Now link it using root view controller. (Ctrl+Click on Navigation controller and drag it to the View controller and Select the option "root view controller")

这篇关于推送视图后 UINavigationController 显示黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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