【问题标题】:Open URL coming from Server in Webview在 Webview 中打开来自服务器的 URL
【发布时间】:2015-10-13 18:40:37
【问题描述】:
NSURL *homeURL = [NSURL URLWithString:[self URLEncodeString:URL]];
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:homeURL];

    //Set our self as the webview delegate (so methods below will be called)
    [myWebView setDelegate:self];

    //Start loading the webview's request
    [myWebView loadRequest:request];

在我的 iPad 应用程序中,我使用 Webview(工作得很好)来打开来自服务器的 URL。 在我的一个 URL 中,我得到问题 URL 如下:

www.google.com

如果上面的 URL 我把它放在网上,它只是用 https 前缀打开......我的 URL 可以是任何类型......并且取决于用户输入......

有什么通用的方法可以打开上面的网址....

【问题讨论】:

    标签: objective-c ipad webview


    【解决方案1】:

    您可能必须实现 NSURLConnectionDelegate。

    - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace 
    
    - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
    
    -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
    

    【讨论】:

      猜你喜欢
      • 2021-12-28
      • 1970-01-01
      • 2013-02-05
      • 1970-01-01
      • 2016-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多