2016-09-23 40 views
1

相同的網址在低於iOS10(例如iOS8,iOS9)的情況下運行正常。WebView Url在iOS10中沒有滿載?

-(void) loadUrl 

{ 
    NSString *urlAddress = @"http://myurl.com"; 

    //Create a URL object. 
    NSURL *url = [NSURL URLWithString:urlAddress]; 

    //URL Requst Object 
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 

//Load the request in the UIWebView. 
    [detailWebView loadRequest:requestObj]; 
} 

回答

0

我想你的代碼,並在IOS 10工作正常,Xcode中8

我用這個,

-(void) loadUrl 

{ 
    NSString *urlAddress = @"http://google.com"; 

    //Create a URL object. 
    NSURL *url = [NSURL URLWithString:urlAddress]; 

    //URL Requst Object 
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 

    //Load the request in the UIWebView. 
    [self.webView loadRequest:requestObj]; 
} 

而且調用這個方法您想使用

在您的plist文件中爲您的網址添加URLSchemes。

我越來越喜歡的WebView,

ios 10 WebView

您的代碼是沒有錯的。

希望這會幫助你。

+0

的WebView鏈接在iOS10沒有完全加載它只是部分負荷應用。爲問問題我使用了虛擬url。 – Nikunj

+0

你可以發佈你所得到的圖片嗎? @Nikunj – KAR

0

在在iOS 8的運行和更高版本,使用WKWebView類,而不是使用UIWebView.import webkit.h,並使用此代碼

#import <WebKit/WebKit.h> 
WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init]; 
WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration]; 
NSURL *nsurl=[NSURL URLWithString:@"http://www.apple.com"]; 
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl]; 
[webView loadRequest:nsrequest]; 
[self.view addSubview:webView]; 
+0

同樣的問題,不工作.. – Nikunj

+0

這個蘋果網址也沒有正確加載。 –