iOS Question How to zoom out of Webview

Falcon

Member
Licensed User
Hi Guys,

The problem I have is that when I load a URL into a webview it is zoomed in too much and cuts part of the content off (see screenshot).

In B4A I could do this to control the zoom of the webview:

B4X:
    Dim Obj1 As Reflector
    Obj1.Target = PaygateBrowser
    Obj1.RunMethod2("setInitialScale", "200", "java.lang.int")

I have locked my app in Portrait mode, and it looks fine on an Ipad, it is just on the Iphone 12 that it does this.

How do I fix this problem in B4i?


Regards
Jacques.
 

Attachments

  • IMG_1746 (002).PNG
    IMG_1746 (002).PNG
    105.8 KB · Views: 237

Semen Matusovskiy

Well-Known Member
Licensed User
Add something like <meta name=viewport content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0'> to header.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Have you tried creating a responsive site to load in the WebView?
Another option is to load it in SafariController.

Edit: Please also note that if you sell digital goods you will have to do it through InApp Purchases as only for physical goods Apple allows an outside charging institution.
 
Upvote 0

Falcon

Member
Licensed User
@ Semen, thank you, but I cannot add a header in the webpage markup as it is not my webpage, it is a payment gateway's website that I am showing in the webview.
@ Hatzisn, also thanks, but same problem it is not my website so I cannot modify it.

Any other ideas guys?
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
In _PageFinished you can do, for example:
B4X:
Dim javaScript  As String = $"
    var meta = document.createElement ('meta');
    meta.setAttribute ('name', 'viewport');
    meta.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=yes');
    document.getElementsByTagName ('head') [0].appendChild (meta);
    "$

    WebView1.EvaluateJavaScript (javaScript)

I am not sure that a problem is relative to zoom scale. Probably incorrect webpage design. But you can play with initial-scale (shold be between minimum amd maximum scale)
 
Upvote 0
Top