I’m using a StoryBoard which contains various ViewControllers and a TableViewController, one in particular is ImageViewController which just displays an image. My DetailViewController contains a UIWebView, here I have a link, when pressed I am trying to load a my ImageViewController.
The link is
View Image
`
In AppDelegate.m I get the filename value by handling handleOpenURL.
I’m new to IOS and struggling how to load my ImageViewController from the handleOpenURL method in AppDelegate.m.
My code is:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
NSString *param = [keyValueParm objectForKey:@"filename"];
NSLog(@"Param: %@",param);
ImageViewController *imageViewController =[[ImageViewController alloc]init];
imageViewController.imageString = param;
UIViewController *root = self.window.rootViewController;
[root.navigationController pushViewController:imageViewController animated:YES];
return true;
}
At present nothing happens.
You should’t implement the
application:handleOpenURL:method. Not only it is deprecated, but what it does is ask the application delegate to allow opening an URL in the browser.What you want to do instead is implement the
UIWebViewControllerDelegateprotocol in theDetailViewController. Specifically you should implement the– webView:shouldStartLoadWithRequest:navigationType:method. In it:In this method, the
UIWebViewinstance asks its delegate for permission to open an url.Hope it helps