iOS Question Use WebView to show images

jahswant

Well-Known Member
Licensed User
Longtime User
This seems not to work on iPhone 6 on iOS 11. Don’t understand why. Only a white page is showed.


B4X:
xui is a global XUI object.
Private Sub ShowImage(WV As WebView, Dir As String, FileName As String)
#if B4A
    Dim jo As JavaObject = Me
    jo.RunMethod("zoom", Array(WV))
#End If
    If xui.IsB4J Then
        WV.LoadHtml($"<img src="${xui.FileUri(Dir, FileName)}"/>"$)
    Else
        If Dir = File.DirAssets Then FileName = FileName.ToLowerCase
        If xui.IsB4A Or Dir = File.DirAssets Then
            WV.LoadHtml($"<img src="${xui.FileUri(Dir, FileName)}"/>"$)
        Else
            WV.LoadUrl("file://" & File.Combine(Dir, FileName))
        End If
    End If
End Sub

#if Java AND B4A
public static void zoom(android.webkit.WebView wv) {
   wv.getSettings().setUseWideViewPort(true);
   wv.setInitialScale(1);
}
#End If
 

Semen Matusovskiy

Well-Known Member
Licensed User
Replace WV.LoadUrl("file://" & File.Combine(Dir, FileName)) by
B4X:
WV.LoadUrl (xui.FileUri(Dir, FileName))

Guess, your file name includes special symbols (for example, space or ANSI codes 128-255).
 
Upvote 0
Top