iOS Question Set ImageSlider. Types does not match.

Discussion in 'iOS Questions' started by ykucuk, Sep 12, 2018.

  1. ykucuk

    ykucuk Active Member Licensed User

    Hi. i'm trying to find ImageSlider view by Tag. When i wrote code as below i got a warning "Types does not match".
    How can i set ImageSlider view with return view of FindViewByTag function
    Any help ?

    Code:
    Dim slider As ImageSlider= FindViewByTag(p,"ImageSliderX"' Types does not match".

     
    Sub FindViewByTag(Parent As Panel, Name As StringAs View

    Try
    For Each v As View In Parent.GetAllviewsRecursive
    If Name = v.Tag And v Is ImageView Then
    Return v
    End If
    If Name = v.Tag And v Is TextView Then
    Return v
    End If
    If Name = v.Tag And v Is TextField Then
    Return v
    End If
    If Name = v.Tag And v Is Button Then
    Return v
    End If
    If Name = v.Tag And v Is Picker Then
    Return v
    End If
    If Name = v.Tag And v Is Label Then
    Return v
    End If
    If Name = v.Tag And v Is ImageView Then
    Return v
    End If
    If Name = v.Tag And v Is Switch Then
    Return v
    End If
    If Name = v.Tag And v Is Panel Then
    Return v
    End If
    If Name = "ImageSliderX" Then '***** It's works  but i cant set view by imageslider
    Return v
    End If
    Next
    Catch
    'Showerror("FindViewByTag:" & LastException  )
    End Try
    End Sub
     
    Last edited: Sep 12, 2018
  2. Erel

    Erel Administrator Staff Member Licensed User

    1. This code can be replaced with:
    Code:
    Sub FindViewByTag(Parent As Panel, Name As StringAs View
    For Each v As View In Parent.GetAllviewsRecursive
    If Name = v.Tag Then
    Return v
    Next
     
    Return Null
    End Sub
    There is no reason for these type checks.

    2. ImageSlider is not a view by itself. A simple way to get an ImageSlider based on its name is with a global Map that maps between the name and the ImageSlider.
    Code:
    Dim slider As ImageSlider = Sliders.Get(Name)
     
  3. ykucuk

    ykucuk Active Member Licensed User

    Hello Erel,

    Thanks for replacing function.

    I think my English is not enough how to explain well what is my problem. I created an example project about what is my problem. Code doesn't work well (cant add correct images and cant slide ). Could you run the code and try slide images in imageslider?

    Thank you.
     

    Attached Files:

  4. Erel

    Erel Administrator Staff Member Licensed User

  5. ykucuk

    ykucuk Active Member Licensed User

    You are the best. 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