[英]Open a new ViewController from a current view controller
I know there are a few other question out there like this, however I'm not able to get any of them to work. 我知道这里还有其他一些问题,但是我无法让其中任何一个工作。 I think I need a little more clarification that I'm attacking this correctly. 我想我需要进一步澄清一下我正在正确地进行攻击。
I have a story board that I have a NavigationController on with a segue to a ViewController that contains a webview. 我有一个故事板,上面有一个NavigationController,并带有一个包含Webview的ViewController。 I have successfully captured the the click on my webview and I would like it to open in a new ViewController that also contains a webview. 我已经成功捕获了Webview上的点击,我希望它在一个也包含Webview的新ViewController中打开。 I have added a second ViewController with a webview on to my storyboard, but can't figure out how to add a segue to it. 我在情节提要中添加了第二个具有Webview的ViewController,但无法弄清楚如何为其添加序列。 I also tried making the connection in the code by adding the following to my shouldStartLoadWithRequest method of my first ViewController: 我还尝试通过将以下内容添加到我的第一个ViewController的shouldStartLoadWithRequest方法中来建立代码连接:
SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self presentViewController:secondViewController animated:YES completion:nil];
However it never opens my second ViewController, it just stays in the first ViewController. 但是,它永远不会打开我的第二个ViewController,而是停留在第一个ViewController中。 I'm a noob and I'm sure I'm missing something somewhere? 我是菜鸟,可以确定我在某处缺少什么吗?
Just add the segue from one view controller to the other (not connected to any specific button), and then give the segue an identifier. 只需将一个视图控制器中的序列添加到另一个视图控制器(未连接到任何特定按钮),然后为该序列提供一个标识符。
Then, in your code, remove the initWithNibName
, because you don't have a NIB. 然后,在您的代码中,删除initWithNibName
,因为您没有NIB。 Instead, use performSegueWithIdentifier:sender:
. 而是使用performSegueWithIdentifier:sender:
You will also likely want to use prepareForSegue:sender:
in order to pass the appropriate URL / HTML information that should be loaded into the second web view. 您可能还需要使用prepareForSegue:sender:
以传递应加载到第二个Web视图中的适当的URL / HTML信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.