Я попытался открыть ниже URL в WebViewКак открыть URL в WebView в iOS?
http://1-dot-smartrefill-968.appspot.com/#/#[email protected]_com
Но не смог сделать объект из NSURL
.
Я попытался открыть ниже URL в WebViewКак открыть URL в WebView в iOS?
http://1-dot-smartrefill-968.appspot.com/#/#[email protected]_com
Но не смог сделать объект из NSURL
.
Шаг-1
initially add
NSAppTransportSecurity
in your .plist, see this
шаг-2
call the url like
NSString *urlAddress = @"http://1-dot-smartrefill-968.appspot.com/#/#[email protected]_com";
[self.yourwebviewName loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSURL URLWithString:[urlAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]]];
NSString * strUrl = [[NSString stringWithFormat: @"% @ % @ ", ITEM_URL, [AppDelegate_.usermanager userName]] stringByAddingPercentEncodingWithAllowedCharacters: [NSCharacterSet URLPathAllowedCharacterSet]]; NSURLRequest * request = [NSURLRequest requestWithURL: [NSURL URLWithString: strUrl]]; [сам.webView loadRequest: request]; –
@AshokD - в этом месте '[[NSString stringWithFormat: @"% @% @ ", ITEM_URL, [AppDelegate_.usermanager userName]] stringByAddingPercentEncodingWithAllowedCharacters: [NSCharac terSet URLPathAllowedCharacterSet]];' попробуйте мой ansswer один раз –
, где ваш код? Вы использовали webView?
[_webView loadRequest:[NSURLRequest requestWithURL:url]];
Я использую этот способ.
хороший человек .. ...... –
Я пробовал все это, а затем опубликовал этот вопрос. NSURL не создается, он имеет значение null с этим URL-адресом. –
Для быстры:
var url : NSString = "http://1-dot-smartrefill-968.appspot.com/#/#[email protected]_com"
var urlStr : NSString = url.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
var searchURL : NSURL = NSURL(string: urlStr)!
webviewInstance.loadRequest(NSURLRequest(URL: searchURL))
Для Objective-C
[webviewInstance loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSURL URLWithString:[your_URL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]]];
Я пробовал все это, а затем опубликовал этот вопрос. NSURL не создается, он имеет значение null с этим URL-адресом. –
вы сделали 'NSUTF8StringEncoding' с вашей строкой url? –
Да, я пробовал. Но webview не загружает этот URL. –
Try для кодирования URL
с помощью addingPercentEncoding
вместо stringByAddingPercentEscapesUsingEncoding
, потому что она устарела.
В Swift:
Для Swift 3:
let strUrl = "http://1-dot-smartrefill-968.appspot.com/#/#[email protected]_com"
let encodedUrl = strUrl.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
для Swift 2.3 или ниже:
let encodedUrl = strUrl.stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet())
В Objective-C
NSString *strUrl = @"http://1-dot-smartrefill-968.appspot.com/#/#[email protected]_com";
NSString *encodedUrl = [strUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
Этот URL-адрес не является загружаемым веб-просмотром, то есть ошибкой. Может ли PLS предложить? –
@AshokD Вы проверили этот http://stackoverflow.com/questions/19713610/how-to-resolve-frame-load-interrupted-error-in-uiwebview и этот http://stackoverflow.com/questions/23473780/ ИОС-UIWebView-кадр нагрузки прерываться –
, на каком языке у попробовал это в объективном C или стремительной добавить тега языка и показывать попытался код –
NSString * strUrl = [[NSString stringWithFormat: @ "% @% @ ", ITEM_URL, [AppDelegate_.usermanager userName]] stringByAddingPercentEncodingWithAllowedCharacters: [NSCharacterSet URLPathAllowedCharacterSet]]; NSURLRequest * request = [NSURLRequest requestWithURL: [NSURL URLWithString: strUrl]]; [self.webView loadRequest: request]; –
#define ITEM_URL @ "http://1-dot-smartrefill-968.appspot.com/#/#" –