iOS Question Help Creating Slideshow with scrollview

Discussion in 'iOS Questions' started by Mashiane, May 27, 2015.

  1. Mashiane

    Mashiane Expert Licensed User

    Hi

    I'm trying to create an image slideshow using a scrollview, Im reading my images from the database, everything works fine, but the only image that gets shown is the last image but when i count the number of views in the scrollview it returns the right number of images.

    Code:
    Sub LoadSlideShow()
        b4iMash.ShowProgress(
    "Loading slideshow...")
        b4iMash.OpenDb
        
    ' clear all views in the panel
        svSlideShow.Panel.RemoveAllViews
        
    Dim cur As ResultSet
        
    Dim sPath As String
        cur = b4iMash.Table_OpenRecordset(b4iMash.SQLite,
    "select * from [Pictures] order by [Key]")
        
    Do While cur.NextRow
            
    Dim sKey As String: sKey = cur.GetString("Key")
            
    Dim sText As String: sText = cur.GetString("Text")
            
    Dim sTag As String: sTag = cur.GetString("Tag")
            sPath = sTag.replace(
    "[","")
            sPath = sPath.replace(
    "]","")
            sPath = sPath.replace(
    ",","")
            sPath = sPath.replace(
    "-","")
            sPath = sPath.ToLowerCase & 
    ".jpg"
            
    ' load a new panel and inset image
            Dim pnlImage As Panel
            pnlImage.Initialize(
    "")
            pnlImage.LoadLayout(
    "slideImage")
            
    ' get the parent panel
            pnlMaster = pnlImage.GetView(0)
            
    ' get the label inside the panel
            lblTitle = pnlMaster.GetView(0)
            lblTitle.Text = sText
            imgPicture = pnlMaster.GetView(
    1)
            imgPicture.Bitmap = 
    LoadBitmap(File.DirAssets, sPath)
            svSlideShow.Panel.AddView(pnlImage,
    0,0,svSlideShow.Width,svSlideShow.Height)
            svSlideShow.ContentWidth = pnlImage.Width
            svSlideShow.ContentHeight = pnlImage.Height
        
    Loop
        cur.close
        b4iMash.HideProgress
    End Sub
    Can anyone please advise please?
     
  2. Brian Robinson

    Brian Robinson Active Member Licensed User

    Code:
    svSlideShow.Panel.AddView(pnlImage,0,0,svSlideShow.Width,svSlideShow.Height)
    Hi,

    It looks like you are just putting the pnlImage objects over the top of each other.

    I think it would need something like this.

    Code:
    Dim counter As Int = 0
    Do While cur.NextRow
        svSlideShow.Panel.AddView(pnlImage,counter*svSlideShow.Width,
    0,svSlideShow.Width,svSlideShow.Height)
        counter = counter+
    1
    Loop
    svSlideShow.ContentWidth = svSlideshow.Width * counter
     
    Mashiane likes this.
  3. Mashiane

    Mashiane Expert Licensed User

    Thanks, its working... now I know.
     
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