ios - WebView自动添加文件://before URL
<p><p>我在我的应用程序中添加了自定义 URL Scehme。喜欢 myapp://</p>
<p>所以每当它检测到 myapp://<a href="http://google.com" rel="noreferrer noopener nofollow">http://google.com</a> .它应该重定向到我的应用程序。以及如何在 webview 上显示 URL。</p>
<p>在 Appdelegate:</p>
<pre><code>- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
NSString *strURL = ;
WebViewController *objWebView = [ initWithNibName:@"WebViewController" bundle:nil] ;
objWebView.url=strURL;
[[keyWindow].rootViewController presentViewController:objWebView animated:YES completion:NULL];
return YES;
}
</code></pre>
<p>但是当我使用该 URL 加载请求时。它在该 URL 之前附加 file://我如何在 WebView 中加载 URL。</p>
<pre><code>NSURL *targetURL = ;
NSURLRequest *request = ;
NSLog(@"%@",request.URL); // O/P :htpp//google.com
</code></pre>
<p>开启 <code>shouldStartLoadWithRequest</code></p>
<pre><code> -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
{
NSLog(@"%@",request.URL);file://htpp//google.com
return true;
}
</code></pre>
<p>最后它失败并出现错误</p>
<blockquote>
<p>Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not
found on this server." UserInfo=0x7983bb30
{NSErrorFailingURLStringKey=file://htpp//google.com,
NSErrorFailingURLKey=file://htpp//google.com,
NSLocalizedDescription=The requested URL was not found on this
server., NSUnderlyingError=0x78fbbe70 "The requested URL was not found
on this server."}</p>
</blockquote></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您的网址错误。 <code>htpp//google.com</code> 是什么?应该是 <code>http://google.com</code></p></p>
<p style="font-size: 20px;">关于ios - WebView自动添加文件://before URL,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/27844286/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/27844286/
</a>
</p>
页:
[1]