[英]Swift 3 - Close current ViewController and Open new ViewController
[英]Open a new ViewController from a current view controller
我知道这里还有其他一些问题,但是我无法让其中任何一个工作。 我想我需要进一步澄清一下我正在正确地进行攻击。
我有一个故事板,上面有一个NavigationController,并带有一个包含Webview的ViewController。 我已经成功捕获了Webview上的点击,我希望它在一个也包含Webview的新ViewController中打开。 我在情节提要中添加了第二个具有Webview的ViewController,但无法弄清楚如何为其添加序列。 我还尝试通过将以下内容添加到我的第一个ViewController的shouldStartLoadWithRequest方法中来建立代码连接:
SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self presentViewController:secondViewController animated:YES completion:nil];
但是,它永远不会打开我的第二个ViewController,而是停留在第一个ViewController中。 我是菜鸟,可以确定我在某处缺少什么吗?
只需将一个视图控制器中的序列添加到另一个视图控制器(未连接到任何特定按钮),然后为该序列提供一个标识符。
然后,在您的代码中,删除initWithNibName
,因为您没有NIB。 而是使用performSegueWithIdentifier:sender:
您可能还需要使用prepareForSegue:sender:
以传递应加载到第二个Web视图中的适当的URL / HTML信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.