iOS Tap at Top of Screen

On an iOS Screen, if you have a iOSMobileTable with a list of many items, and you’ve scrolled down that list a ways or even to the very bottom of the list, and you tap the very, very top of the screen, that table will then auto scroll back to the top of the list. If there are multiple tables on that screen, the first time you tap the very top of the screen, the first table will scroll back to the top. The second time you tap the very top of the screen, the second table will scroll back to the top of the list, etc.

Question is: is there an event associated when the very top of the screen is tapped so that some code can be fired off when this event takes place?

That is an action that is an iOS “feature” and works across all apps. The tap is actually not in the app – it is in the top device status bar and AFAIK there is no event associated with it.

Are you wanting to override and pre-empt this behavior? Or take some additional action when it happens?

I’m needing to take some additional actions in my app when this takes place. For example, when I have a list of data in an iOSMobileTable that has multiple sections, for example, and I have a Previous and Next button for the user to navigate between sections. But, if the user taps the very top of the screen and scrolls to the top, I won’t know about it and when the user taps on Previous or Next, it won’t start back from the beginning, but where the Previous and Next left off prior to the auto scroll to the top.

Does that make any sense at all?

I do know what you mean. I personally don’t know what you can do about it. Maybe others will.

@Terry_Eutsler – you can disable this functionality if you want by turning setting its scrollsToTop property using a Declare. Put this code in the Opening event of the table:

Declare Sub setScrollsToTop Lib "Foundation" Selector "setScrollsToTop:" (obj As Ptr, value As Boolean)

setScrollsToTop(Me.Handle, False)

Note: If you get an error about handle being a Ptr instead of an integer, change that first parameter type to Integer.

Hi Greg. I certainly WANT the user to be able to quickly scroll to the top with that functionality. It’s a great feature. I just want to know that the user did it, that’s all.

Check TableExtensionsXC.GetScrollPositionXC in iOSDesignExtensions

Returns the current visible section/row. Returns -1,-1 if table is empty

1 Like

Thanks Jeremie,

I’m trying not to use any outside plugins or extensions if at all possible. Just using a couple of necessary MBS plugins at the moment.

So, is there no way to query the iOSMobileTable to know what row is currently visible at the top of the list to know if the user tapped the top of the screen or manually scrolled the list back to the top?

Yes there is. Check the code in TableExtensionsXC.GetScrollPositionXC

Is there no way to check this with the native Xojo code?

Youll need to use the declares for it, which is what Jeremie’s design extensions do. If you dont want to copy over the entire project you can just copy the relevant code. Many things in Xojo iOS require declares which is why projects like iOSDesignExtensions and iOSKit exist.

1 Like
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.