SVModalWebViewController - 从 UIWebView 传递 URL

SVModalWebViewController - Pass URL from UIWebView

我有一个主 UIWebView,我正在尝试使用 SVWebViewController 打开任何 URL。我的代码如下所示。

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    if (navigationType == UIWebViewNavigationTypeLinkClicked ) {
        SVModalWebViewController *webViewController = [[SVModalWebViewController alloc] initWithAddress:@"http://google.com"];
        [self presentViewController:webViewController animated:YES completion:NULL];
        return NO;
    }

    return YES;
}

似乎 SVWebViewController 有一个 initWithAddress 参数。我想知道我是否可以在该参数中传递请求的 URL。

提前致谢。

找到解决办法。看来我可以和

一起工作

initWithURLRequest:(NSURLRequest *)request

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    if (navigationType == UIWebViewNavigationTypeLinkClicked ) {
        SVModalWebViewController *webViewController = [[SVModalWebViewController alloc] initWithURLRequest:(NSURLRequest *)request];
        [self presentViewController:webViewController animated:YES completion:NULL];
        return NO;
    }

    return YES;
}