iOS Question ScrollChanged event: Scrollview inside a Scrollview

Marcus Araujo

Member
Licensed User
Longtime User
Inside one main scrollview (parent) I have several panels placed vertically, each panel contains other scrollviews (children). The children contain page indicators (UIPageControl).

It's as in the picture.

1iivIEi.png


The problem I am facing is that I need to get the children's event _ScrollChanged fired, because I need to indicate in UIPageControl the current page, but it's not getting fired. I suspect that there is an interception of _ScrollChanged between the children and the parent scrollview.

Any ideas?
 
Yes, both are scrolling fine. In B4a, the event is fired, though.

The main difference besides the operating system/architecture, is that in B4a, I am using AHViewPager and in B4i, iMashPager, as a child.

The only thing I want to achieve is to know when user switched pages, that's all that matters.
 
Upvote 0
One way i would go about doing that is catch the _Touch event on the scrollview's panel and follow steps in order to figure out what the user is doing.

Step 1: catch if its an horizontal scroll (Action_Move if new X > old_x by 100dip (example))
Step 2: catch the relative scrollview by going through a loop:

Code:
For each v as view in sv.panel.Getallviewsrecursive
if(v is scrollview)then
dim tempscroll as scrollview = v
if(tempscroll.top > y and (tempscroll.top+tempscroll.height)<y)then
'This is the scrollview targeted
'Act accordingly in relation to the Action Move direction
end if
end if

I do things like this and it works very well. It does depend on the number of views you have in the main scrollview. if there are a lot of views you will slow down the app for sure because of the loop.

I am unsure if thats what you are looking for. I am just trying to help ;)

Y.
 
Upvote 0
Thanks for the tips, colleagues! I have deeply analyzed the differences and found one clue: actually only the last child works (they're all added dynamically).
 
Upvote 0
Back
Top