iOS Question Request for page scroll tutorial

Andrew Lindsay

Member
Licensed User
Longtime User
Is there anyone that could provide a short example of how to scroll a text box up above the height of a keyboard?
I have played around a bit but can't seem to get it to work.
Best regards
Andrew
 

Ed Brown

Active Member
Licensed User
Longtime User
I've downloaded the scrollview example (thank you) but I'm not able to scroll.
Am I missing something crucial?

What I am expecting is that the scrollview is loaded with a layout and when the iPhone is flipped horizontally then the scrollview will allow the loaded layout within it to be scrolled.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This example demonstrates how you can use a ScrollView to allow the user to scroll the layout when the keyboard appears. It is similar to Android built-in pan mode.

This is the complete code:
B4X:
Private Sub Page1_Resize(Width As Int, Height As Int)
   ScrollView1.ContentHeight = Height
   ScrollView1.ContentWidth = Width
   ScrollView1.Height = Height - KeyboardHeight
End Sub

Private Sub Page1_KeyboardStateChanged (Height As Float)
   KeyboardHeight = Height
   If Page1.RootPanel.Width > 0 And Page1.RootPanel.Height > 0 Then
     Page1_Resize(Page1.RootPanel.Width, Page1.RootPanel.Height)
   End If
End Sub

It will not be scrollable if the keyboard is not visible. You can change the content height for this.
 
Upvote 0

Ed Brown

Active Member
Licensed User
Longtime User
You can change the content height for this.

This was the missing link for me. I made the assumption that the scrollview would scroll the contents of the layout once the panel had been loaded with the layout. I needed to set the ContentHeight to the height of the loaded layout.
 
Upvote 0
Top