0
votes

I have been working on one app in iOS platform where it need of display HTML files in WebView. Where my UIWebview is not working same as like browsers result.

i.e., Created folder reference in my xcode project and got the bundle path of the HTML file and loaded in UIWebView with NSURLRequest.

Is there any other way to run the HTML file in UIWebView like iphonehttpserver, GCDWebServer(But I am unable to get the demo code to start my server to achieve my requirement)

This is the code where I used to get HTML file path from resource bundle and loading in UIWebView (Folder name "assets" in which I have "web-app.html" file):

Objective-c:

 - (void)viewDidLoad
  {
   [super viewDidLoad];
   [self loadWebview];
  }

 - (void)loadWebview
  {
   NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"web-app" ofType:@"html" inDirectory:@"assets"];
   NSURL *url = [NSURL fileURLWithPath:htmlPath];
   [webVW loadRequest:[NSURLRequest requestWithURL:url]];
  }
1
Try using WKWeb​View or SFSafari​View​Controller - pckill
i. Using WKWebView I have experienced same result like UIWebview. ii. SFSafariViewController I am not supposed to load HTML file it requires only HTTP url. Because of this reason I went on creating Local server using iPhonehttpserver, GCDWebServer but without demo I am unable to go forward to resolve this. Thanks for your response. - Abilash Balasubramanian
What do you mean by "not working same"? Is it not rendering something? Is the font/color not the same? - izerik
For instance: In browsers(chrome,safari) during HTML file loading, start with loader then I will get some data or No data found message. But in UIWebView only starting loader keep on loading without giving any results. My Html folder has some files like css,.json etc. - Abilash Balasubramanian
Result is not exact which I am getting in browser. Similar HTML file also working fine in Android webview like browser. - Abilash Balasubramanian

1 Answers

0
votes

We found the issue, there was one servers.json file missing at our end. Because of that HTML unable to get the response to display the appropriate result.