Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
来自AppDelegate.h的IOS推送ViewController_Ios_Uiviewcontroller - Fatal编程技术网

来自AppDelegate.h的IOS推送ViewController

来自AppDelegate.h的IOS推送ViewController,ios,uiviewcontroller,Ios,Uiviewcontroller,我使用的是一个故事板,其中包含各种ViewController和一个TableViewController,其中一个是ImageViewController,它只显示一个图像。My DetailViewController包含一个UIWebView,在这里我有一个链接,当按下时,我试图加载My ImageViewController 链接是查看图像` 在AppDelegate.m中,我通过处理handleOpenURL获得文件名值 我是IOS新手,正在努力从AppDelegate.m中的hand

我使用的是一个故事板,其中包含各种ViewController和一个TableViewController,其中一个是ImageViewController,它只显示一个图像。My DetailViewController包含一个UIWebView,在这里我有一个链接,当按下时,我试图加载My ImageViewController

链接是查看图像`

在AppDelegate.m中,我通过处理handleOpenURL获得文件名值

我是IOS新手,正在努力从AppDelegate.m中的handleOpenURL方法加载ImageViewController

我的代码是:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
{

}


目前什么都没有发生。

您不应该实现
应用程序:handleOpenURL:
方法。它不仅不推荐使用,而且要求应用程序委托允许在浏览器中打开URL

您要做的是在
DetailViewController
中实现
UIWebViewControllerDelegate
协议。具体来说,您应该实现
–webView:shouldStartLoadWithRequest:navigationType:
方法。其中:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
   [ImageViewController *imageViewController =[[ImageViewController alloc]init];
   imageViewController.imageString = param;
   [root.navigationController pushViewController:imageViewController animated:YES];

   return YES;
} 
在此方法中,
UIWebView
实例请求其委托人授予打开url的权限


希望它有助于

注意,此方法取决于:

另外,请确保让您的应用程序代理application:didFinishLaunchingWithOptions:method返回YES,或者如果您的代理实现了applicationDidFinishLaunching:,则不会调用您的代码:


如果委托从其应用程序:didFinishLaunchingWithOptions:方法的实现返回NO,则不会调用此方法。如果应用程序实现了ApplicationIDFinishLaunching:方法而不是application:didFinishLaunchingWithOptions:,则在应用程序初始化后,将调用此方法打开指定的URL。

我无法使其正常工作。我确保我的DetailViewController.h实现了协议:@interface DetailWebViewController:UIViewController,并添加了shouldStartLoadWithRequest。我还添加了webViewDidStartLoad和webViewDidFinishLoad,这些方法会被调用,但我必须添加webView.delegate=self;在viewDidLoad方法中。单击webView中的链接时不会发生任何情况,我的链接为:。我遗漏了什么吗?我不知道它是否与URL有关。“eft”是什么东西?尝试使用更常见的URL。像
http://www.google.com
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
   [ImageViewController *imageViewController =[[ImageViewController alloc]init];
   imageViewController.imageString = param;
   [root.navigationController pushViewController:imageViewController animated:YES];

   return YES;
}