所以我有一个UINavigationController
堆栈。此堆栈中的UIViewControllers
之一有UIButton
,它添加了一个子UIViewController
来实现模态外观(它是一个具有模糊,半透明背景的菜单)。代码如下,工作得很好。
var childVC = storyboard!.instantiateViewControllerWithIdentifier("Extra") as! UIViewController
childVC.view.frame = CGRectMake(0, 0, self.view.frame.width, UIScreen.mainScreen().bounds.height)
self.navigationController?.addChildViewController(childVC)
self.navigationController?.didMoveToParentViewController(childVC)
self.navigationController?.view.addSubview(childVC.view)
但在Child UIViewController
内部,我需要在堆栈顶部推送UIViewController,即在Parent UIViewController上。我已经尝试了很多东西,但我能得到的最好的是用self.navigationController?.pushViewController
打开一个空白屏幕 - 这会运行下一个UIViewController中的代码(例如它打印到控制台)但显然有问题显示黑屏。我也试过self.parentViewController?.navigationController?.pushViewController
编辑:,如果我打印出顶部UIViewController的println(self.navigationController!.viewControllers)
中的堆栈viewDidLoad
,即显示空白的堆栈UIViewController
。它按预期打印:第一个UIViewController
,模态UIViewController
和顶部<h1>Cascading Style Sheets (CSS)</h1>
<p>Cascading Style Sheets (CSS) is a style sheet language used for describing the
look and formatting of a document written in a markup
language <span class="sidenote" data-source="src1"></span>.
Although most often used to change the style of web pages and user
interfaces written in HTML and XHTML, the language can be applied to
any kind of XML document, including plain XML, SVG and XUL. Along with
HTML and JavaScript, CSS is a cornerstone technology used by most websites
to create visually engaging webpages, user interfaces for web applications,
and user interfaces for many mobile applications <span class="sidenote" data-source="src2"></span>.</p>
<h3>References</h3>
<ul id='references'></ul>
。