1. Black Friday Sale - 50% off

    B4A Standard for $29 instead of $59!
    Buy Now
    Dismiss Notice

iOS Question ScrollView Layout not scrolling

Discussion in 'iOS Questions' started by aaronk, Oct 14, 2018.

  1. aaronk

    aaronk Well-Known Member Licensed User

    Hi,

    I can't seem to get my layout to work correctly in a scrollview.

    I have a layout called 'Layout1' this contains a bunch of objects in a panel. This panel is 610dip in height.

    I have created another layout which has a ScrollView in it (ScrollView1). This layout is called 'ScrollViewLayoutOnly'.

    I have loaded the 'ScrollViewLayoutOnly' layout and then tried to load the 'Layout1' in the scrollview like:
    Code:
    Dim nc As NavigationController
        nc.Initialize(
    "nc")
        NavControl = nc
        
        Page1.Initialize(
    "Page1")
        
        
    Dim lp As Page
        lp.Initialize(
    "lp")
        lp.RootPanel.Color = 
    Colors.Red
        
    Dim rp As Page
        rp.Initialize(
    "rp")
        rp.RootPanel.Color = 
    Colors.Green
        smc.Initialize(
    Null, nc, Null)
        Main.app.KeyController = smc
        Page1.HideBackButton = 
    True
        NavControl.SetNavigationBarVisibleAnimated(
    False)
        
        Page1.RootPanel.Color = 
    Colors.Blue
        
        Page1.RootPanel.LoadLayout(
    "ScrollViewLayoutOnly")    ' only has a ScrollView1
        ScrollView1.Panel.LoadLayout("Layout1")    ' has my layout with a panel which is 610dip in height
        
        ScrollView1.Left = 
    0dip
        ScrollView1.Width = 
    100%x
        ScrollView1.Height = 
    100%y - 50dip - 50dip
        ScrollView1.Top = 
    50dip
        
    ' I want it 50dip from the top of screen, and 50dip from the bottom of the screen
        
        ScrollView1.Panel.Height = 
    610dip
        ScrollView1.Panel.Width = 
    100%x
        
        nc.ShowPage(Page1)
    The issue I have is it doesn't scroll, and the scrollview is at the top of the screen.
    The layout isn't also 100% the width of the screen.

    Anyone know where I have gone wrong ?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Can you upload the project?
     
  3. aaronk

    aaronk Well-Known Member Licensed User

    Attached..

    I had it in my main app, but just created the attached project for testing. (which is pretty much how I am doing it in my main app)

    This seems to scroll, but still not showing the layout correctly.
     

    Attached Files:

  4. Erel

    Erel Administrator Staff Member Licensed User

    Make sure to go over this example: Multiple Pages Example

    1. Why aren't you using anchors?
    This code should be deleted:
    Code:
    ScrollView1.Left = 0dip
        ScrollView1.Width = 
    100%x
        ScrollView1.Height = 
    100%y - 50dip - 50dip
        ScrollView1.Top = 
    50dip
    Instead set the anchors in ScrollViewLayoutOnly.

    2. You should never assume that %x and %y are correct outside of the Resize event.

    Relevant video tutorial:

     
Loading...
  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