Share My Creation [Class]: iMashPager Sliding Panels adopted from AHViewPager

Discussion in 'iOS Share Your Creations' started by Mashiane, Jul 18, 2016.

Similar threads

B4i Question b4a to b4i: AHViewPager
B4i Library [class] CustomListView
B4A Library [B4X] [class] MJPEG decoder
B4i Library [class] Table
B4i Library [class] SearchView
  1. Mashiane

    Mashiane Well-Known Member Licensed User

    Hi there

    This class is an adoption of the AHViewPager from B4A to enable one to add sliding panels to their iOS apps easily. Thanks to Klaus with help in one of the methods. The inspiration for this started when I was converting my b4a app to b4i and this was the major functionality I needed.

    In essence, this uses a scrollview with paging enabled with added methods to make it function like AHViewPager. There is no need of a "container" though here.

    There is a complete sliding page example here using a PageViewController but I did not want that.

    Copy the module to your shared code module. In the designer, insert this as a custom view.

    The zip file herein contains a working example.

    Attached Files:

    Marcus Araujo, AndOrNot and Erel like this.
  2. Mashiane

    Mashiane Well-Known Member Licensed User

    Added a Refresh method to the class as sometimes it just did not display pages on first run.

    Attached Files:

  3. fbritop

    fbritop Active Member Licensed User

    I believe there is an error on your gotoPage sub. It should be like:

    public Sub GotoPage(Index As Int, bSmooth As Boolean)
        CurrentPage = Index
        sv.ScrollTo((Index) * (sv.Panel.Width/panels.Size), 
    0, bSmooth)
    End Sub
    cloner7801 and Mashiane like this.
  4. Mashiane

    Mashiane Well-Known Member Licensed User

    Thanks a lot for this. Will check it out.
    cloner7801 likes this.
  5. cloner7801

    cloner7801 Active Member Licensed User

    Hi, thanks for this class
    But GotoPage didn't work please help me I change the sub to #3 post but it again didn't work

    Update :

    I use the class in #2 post its GotoPage sub work but ! when I want to change the page it goes to other page(last page)

    I have 3 page and at first I go to page 1
    pager.GotoPage(1, True)

    But when I want to change the page(scroll) it goes to last page
    Last edited: Jan 28, 2017
  6. Leni Berry

    Leni Berry Member Licensed User

    public Sub GotoPage(Index As Int, bSmooth As Boolean)
        CurrentPage = Index
    1) * (sv.Panel.Width/panels.Size), 0, bSmooth)
    End Sub
  7. Mashiane

    Mashiane Well-Known Member Licensed User

    Let me perhaps upload an updated class, please check this version...

    Attached Files:

  8. Marcus Araujo

    Marcus Araujo Member Licensed User

    Thanks a lot, Mashiane! This is very helpful!!

    I have one suggestion, to add the "AddToParent" so we can add the view in runtime. I wrote as below and it worked fine.

    Public Sub AddToParent(Parent As Panel, Left As Int, Top As Int, Width As Int, Height As Int)
        Parent.AddView(mBase, Left, Top, Width, Height)
    "sv", mBase.Width, mBase.height)
    00, mBase.Width, mBase.Height)
        sv.PagingEnabled = 
        sv.ShowsHorizontalIndicator = 
    End Sub
    Mashiane likes this.