ios - baseURL not working for UIWebView? -
i creating uiwebview load nsstring server service. simple html string, load uiwebview this:
urladdress = [[nsurl alloc] initwithstring:urlstring]; //try removing cache new stylesheet shows everytime- not sure if working yet [[nsurlcache sharedurlcache] removeallcachedresponses]; [infowebview loadhtmlstring:returnedhtmlstring baseurl:urladdress];
then reason images not showing , style sheet not working.
for instance baseurl looks this
https://myserveraddress/
and code css looks this
<link rel="stylesheet" type="text/css" href="data/iphone/my.css">
my questions how baseurl prefix onto href? dose request css loadhtmlstring loads onto webview? or different
and how can output infowebview source nsstring? see if baseurl prefixing onto href links? or dose work that?
any appreciated.
how
baseurl
work?
here helpful examples afnetworking documentation:
nsurl *baseurl = [nsurl urlwithstring:@"http://example.com/v1/"]; [nsurl urlwithstring:@"foo" relativetourl:baseurl]; // http://example.com/v1/foo [nsurl urlwithstring:@"foo?bar=baz" relativetourl:baseurl]; // http://example.com/v1/foo?bar=baz [nsurl urlwithstring:@"/foo" relativetourl:baseurl]; // http://example.com/foo [nsurl urlwithstring:@"foo/" relativetourl:baseurl]; // http://example.com/v1/foo [nsurl urlwithstring:@"/foo/" relativetourl:baseurl]; // http://example.com/foo/ [nsurl urlwithstring:@"http://example2.com/" relativetourl:baseurl]; // http://example2.com/
basically, files in html assumed in location specified in base url. if html specifies files beginning /
, domain name stay same path of base url ignored. if html specifies files beginning http(s)://
, entire base url ignored.
in example, url resolve https://myserveraddress/data/iphone/my.css
.
how can output
infowebview
source nsstring?
a simple solution is:
nsstring *html = [infowebview stringbyevaluatingjavascriptfromstring: @"document.body.innerhtml"];
more info , discussion on topic available on stack overflow here.
Comments
Post a Comment