Question

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. 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. 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. I also tried making the connection in the code by adding the following to my shouldStartLoadWithRequest method of my first ViewController:

    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. I'm a noob and I'm sure I'm missing something somewhere?

Was it helpful?

Solution

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. Instead, use 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top