0

I want to integrate webpage into an Ios application. I have created a webpage using D3 js and SVG elements. I am trying to display the webpage on Ipad Pro 12.9" 2nd generation. But somehow it is showing only a 1/4 portion of my webpage in webView.

Here is the webpage URL - http://ec2-54-198-148-171.compute-1.amazonaws.com/webapp/question

I got iPad pro-resolution from apple website which is 1366X1024 so I have created a webpage for the same resolution.

I have verified webpage on browsers like safari, chrome, firefox and it's looking perfect on it with 1366X1024 resolution.

Attached screenshot BrowserScreenCap taken with 1366 X 1024 on browser and IpadAppScreenCap took on iPad application. I am using WKwebView on IOS side. I have verified webpage layout on simulator only. How we make that webpage fullscreen?

BrowserScreenCap iPadAppScreenCap

Blazej SLEBODA
  • 8,936
  • 7
  • 53
  • 93
dang
  • 2,342
  • 5
  • 44
  • 91

3 Answers3

0

Content from the link mentioned in comment.

NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);";

    WKUserScript *wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
    WKUserContentController *wkUController = [[WKUserContentController alloc] init];
    [wkUController addUserScript:wkUScript];

    WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init];
    wkWebConfig.userContentController = wkUController;
Dattatray Deokar
  • 1,923
  • 2
  • 21
  • 31
0
let url: URL = URL(string: "http://ec2-54-198-148-171.compute-1.amazonaws.com/webapp/question")!
webView.loadRequest(URLRequest(url: url))
webView.contentMode = .scaleAspectFit

enter image description here

anshul king
  • 558
  • 4
  • 17
0

add the below tag into your html body

<meta name=\"viewport\" content=\"width=device-width, initial-scale=1,user-scalable=no\">

if you want you can enable user-scable=yes for zooming

Ganesh Manickam
  • 2,113
  • 3
  • 20
  • 28