iOS Question How to prevent reloading of webview?

Baris Karadeniz

Active Member
Licensed User
In my app I have a webview in Page 2. When I press on the button in Page 1, I go to Page 2 and webview opens and I wrote username and password and log in to the web page. Then I go back to Page 1 for some reason. When I go back to to webview (Page 2) again, it reloads the web page and I have to log in again. How can I prevent reloading webview?
 

Baris Karadeniz

Active Member
Licensed User
My codes are given below. Where can be my fault?

B4X:
Sub BtnMap_Click
    NavControl.ShowPage(Page3)
    WebView3.LoadUrl("http://www.xxx.com")
End Sub
 
Upvote 0

Baris Karadeniz

Active Member
Licensed User
I try to detect whether url is loaded before or not but I couldn't do. I wrote the codes below. Where is my fault?

B4X:
Prosess_Globals
Dim UrlLoadedBefore As Boolean

Application_Start
UrlLoadedBefore = False

Sub BtnMap_Click
    NavControl.ShowPage(Page3)
    If UrlLoadedBefore = False Then
    WebView3.LoadUrl("http://www.xxx.com")
    End If
End Sub

Sub WebView3_PageFinished
       UrlLoadedBefore = True
End Sub
 
Upvote 0

Baris Karadeniz

Active Member
Licensed User
Problem occurs again. I didn't understand why. I used to code below to prevent reloading. But I can not have success. Help please. How can I prevent reloading web page if it is loaded before?


B4X:
Sub Process_Globals
Dim UrlLoadedBefore As String
End Sub

Private Sub Application_Start (Nav As NavigationController)
UrlLoadedBefore = "False"
End Sub

Sub BtnMap_Click
    NavControl.ShowPage(Page3)
    If UrlLoadedBefore = "False" Then
    WebView3.LoadUrl("http://www.taksi-m.com.tr/track")
    End If
End Sub

Sub WebView3_PageFinished
       UrlLoadedBefore = "True"
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Why are you using strings instead of booleans?
2. Put a breakpoint in Page_Finished. Is it raised?

3. Correct way to implement events:

test.gif
 
Upvote 0
Top