iOS Question I want ScrollView move in a fix OffsetY after I scroll this Scrollview .

Discussion in 'iOS Questions' started by cambol, Jun 7, 2016.

  1. cambol

    cambol Member Licensed User

    I want ScrollView move in a fix OffsetY after I scroll this Scrollview .
    I can do it in B4A
    How to modify this code for B4i



    Dim Timer As Timer
    Dim sc As ScrollView
    Dim pp As Int


    Timer.Initialize("TimerX", 700)
    DoEvents ------> b4i no DoEvent
    sc.ScrollOffsetY=Round(pp / 20 ) *20




    Sub ScrollViewX_ScrollChanged(Position As Int)
    Dim SV1 As ScrollView
    SV1=Sender
    Timer.Enabled = True
    pp=Position


    Dim r As Reflector ----> b4i no reflector
    r.Target =SV1
    r.RunMethod2("setVerticalScrollBarEnabled", False, "java.lang.boolean")

    End Sub




    Sub TimerX_Tick
    Dim ti As Timer
    ti=Sender
    sc.ScrollOffsetY=Round(pp / Dyy ) *Dyy '
    Timer.Enabled = False
    End Sub
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Please use [code]code here...[/code] tags when posting code.

    You don't need DoEvents to change the scroll position. That is also true in B4A (you should use ScrollView.ScrollToNow).
     
  3. cambol

    cambol Member Licensed User

    This is my code ~

    Code:
    Sub Process_Globals

    Dim sc As ScrollView
    Dim pp As Int

    EndSub



    PrivateSub Application_Start (Nav AsNavigationController)

      NavControl = Nav
      Page1.Initialize(
    "Page1")
      Page1.RootPanel.Color = 
    Colors.White
      NavControl.ShowPage(Page1)
      Page1.RootPanel.LoadLayout(
    "main")


      
    Timer.Initialize("TimerX"700
      sc.ScrollTo(
    0,Round(pp / Dyy ) *Dyy,True)

    EndSub


    Sub TimerX_Tick
      
    Dim ti AsTimer
      ti=
    Sender
      sc.ScrollTo(
    0,Round(pp / Dyy ) *Dyy ,True)
      
    Timer.Enabled = False
    EndSub


    Sub SC_ScrollChanged (OffsetX AsInt, OffsetY AsInt)
      
    Dim SV1 AsScrollView
      SV1=
    Sender
      
    Timer.Enabled = True
      pp=OffsetY

      
    Dim r As Reflector ----> b4i no reflector
      r.Target =SV1
      r.RunMethod2(
    "setVerticalScrollBarEnabled"False"java.lang.boolean")

    EndSub
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You can set sc.PagingEnabled to True and the ScrollView will always scroll to the nearest "page". Remove all other code.
     
  5. cambol

    cambol Member Licensed User

    It is working ~ so amazing , thank you !
     
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