Ich habe versucht, in WebView unter URL zu öffnenWie öffne ich URL in WebView in iOS?
http://1-dot-smartrefill-968.appspot.com/#/#[email protected]_com
aber nicht in der Lage Objekt von NSURL
zu machen.
Ich habe versucht, in WebView unter URL zu öffnenWie öffne ich URL in WebView in iOS?
http://1-dot-smartrefill-968.appspot.com/#/#[email protected]_com
aber nicht in der Lage Objekt von NSURL
zu machen.
Step-1
initially add
NSAppTransportSecurity
in your .plist, see this
Schritt-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 * Anfrage = [NSURLRequest requestWithURL: [NSURL URLWithString: strUrl]]; [selbst.webView loadRequest: Anfrage]; –
@AshokD - an diesem Ort '[[NSString stringWithFormat: @"% @% @ ", ITEM_URL, [AppDelegate_.usermanager userName]] stringByAddingPercentEncodingWithAllowedCharacters: [NSCharac terSet URLPathAllowedCharacterSet]];' versuchen Sie meine Answer einmal –
wo ist dein Code? hast du ein WebView benutzt?
[_webView loadRequest:[NSURLRequest requestWithURL:url]];
Ich verwende diese Methode.
guten Mann .. ...... –
ich habe alles versucht, dann diese Frage stellen. NSURL ist nicht erstellt, es ist null mit dieser URL. –
Für swift:
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))
Für Objective-c
[webviewInstance loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSURL URLWithString:[your_URL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]]];
Ich habe das alles versucht, dann posten Sie diese Frage. NSURL ist nicht erstellt, es ist null mit dieser URL. –
haben Sie 'NSUTF8StringEncoding' mit Ihrem URL-String getan? –
Ja, ich habe es versucht. Aber Webview lädt diese URL nicht. –
Versuchen Sie, Ihre URL
mit addingPercentEncoding
statt stringByAddingPercentEscapesUsingEncoding
zu kodieren, weil es veraltet ist.
In Swift:
für SWIFT 3:
let strUrl = "http://1-dot-smartrefill-968.appspot.com/#/#[email protected]_com"
let encodedUrl = strUrl.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
für SWIFT 2.3 oder niedriger:
let encodedUrl = strUrl.stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet())
In Objective-C
NSString *strUrl = @"http://1-dot-smartrefill-968.appspot.com/#/#[email protected]_com";
NSString *encodedUrl = [strUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
Diese uRL webview nicht geladen wird, das ist ein Fehler. Kann bitte vorschlagen? –
@AshokD Hast Du diesen http://stackoverflow.com/questions/19713610/how-to-resolve-frame-load-interrupted-error-in-uiwebview überprüfen und diese http://stackoverflow.com/questions/23473780/ ios-uiwebview-frame-load-unterbrochen –
, in welcher Sprache versucht u dies in Objective C oder swift Add Sprach-Tag und zeigen Sie Ihren versucht Code –
NSString * StrUrl = [[NSString string: @ "% @% @ ", ITEM_URL, [AppDelegate_.usermanager userName]] stringByAddingPercentEncodingWithAllowedCharacters: [NSCharacterSet URLPathAllowedCharacterSet]]; NSURLRequest * Anfrage = [NSURLRequest requestWithURL: [NSURL URLWithString: strUrl]]; [self.webView loadRequest: Anfrage]; –
#define ITEM_URL @ "http://1-dot-smartrefill-968.appspot.com/#/#" –