iOS Code Snippet WebView "extra"

Discussion in 'iOS Code Snippets' started by susu, Dec 17, 2014.

Similar threads

B4i Tutorial Notifications with actions
B4i Code Snippet CSBuilder text direction
B4i Code Snippet Monitor http requests progress
B4i Tutorial Background Fetch (Downloads)
B4i Tutorial iBeacons
  1. susu

    susu Well-Known Member Licensed User

    B4i didn't have WebView extra library (yet) so I collect the code from around the forum. Hope it's useful for you.

    1. Hide scrollbar of WebView:
    Dim no As NativeObject = WebView1
    2. Set background to transparent:
    Dim no As NativeObject = WebView1
    3. Disable Scroll:
    Dim no As NativeObject = WebView1
    4. Go Back:
    Sub GoBack(wv As WebView)
    Dim no As NativeObject = wv
    If no.RunMethod("canGoBack"Null).AsBoolean = True Then
    End If
    End Sub
    5. Clear Cache:
    Dim no As NativeObject
    I will update more.
    Last edited: Dec 19, 2014
    MarcoRome, Andris, b4auser1 and 6 others like this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    Inject JavaScript:

    Dim no As NativeObject = WebView1
    Log(no.RunMethod("stringByEvaluatingJavaScriptFromString:"Array("your java script here"))
  3. moster67

    moster67 Expert Licensed User

    Snippet to obtain title of loaded webpage (corresponding to the getTitle method in the WebViewXtender-library in B4a).
    This snippet requires that JavaScript is always enabled in UIWebView but apparently it cannot be turned off in iOS so this snippet should always work.

    (Based upon Erel's example for injecting JavaScript)

    Dim no As NativeObject = WebView1
    Last edited: Feb 6, 2015
    b4auser1, Derek Johnson and Erel like this.
  4. klarsys

    klarsys Active Member Licensed User

    This is cool.

    Is there any way to raise an app event from javascript?
  5. Erel

    Erel Administrator Staff Member Licensed User

    You can handle the OverrideUrl event and then navigate to a different page in the JavaScript.
  6. ivan.tellez

    ivan.tellez Active Member Licensed User


    Is there any equivalent to the "WebView.CaptureBitmap" in B4A?

  7. Erel

    Erel Administrator Staff Member Licensed User

  8. youjunjer

    youjunjer Member Licensed User

    Is there any method to detect page on loading, I need to make a msgbox to show "page on loading".
    And if network or website is error or unavailable, I need to redirect to a local page.
    Thank for a lot....
  9. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
  10. joop

    joop Active Member Licensed User

    Instead of full screen , inline media playing

    A Boolean value that determines whether HTML5 videos play inline or use the native full-screen controller.

    B4I code:

    Dim no As NativeObject = WebView1

    And the HTML code :

    <iframe webkit-playsinline width="200" height="200" src="" frameborder="0"></iframe>
    Last edited: Nov 17, 2015
    valentino s likes this.
  11. Baris Karadeniz

    Baris Karadeniz Active Member Licensed User

    Hi, is it possible to get "Main" completely?
  12. Baris Karadeniz

    Baris Karadeniz Active Member Licensed User

    Can please send Main?
  13. Erick Kalugdan

    Erick Kalugdan Member Licensed User

    In B4A there is a method "addJavascriptInterface" so that if I want to call an app Sub from the javascript inside the webview, I just call it via APP.CallSub

    Does this exist in B4i too? How? Sample code would be greatly appreciated.

    Thanks in advance!
  14. youjunjer

    youjunjer Member Licensed User

    what i use is to detect the webview's url.
    for example, when webview load a url compete, it will do an event is load onPageFinished, so that you can do something when the url is what you need
  15. Erel

    Erel Administrator Staff Member Licensed User

    Please post questions in the questions forum.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice