iOS Scrolling: Setting the scroll values

Charles E Buchwald charles at buchwald.ca
Sat Jan 21 21:03:14 EST 2012


Hi List,
I'm having a hard time figuring out how to set the scroll of an iOS scroller.
I have big image "Map" and a 20 x 20 graphic named "Marker" in the scrolling group.
I'd like to set the scrolling of the such that "Marker" is centered in the window when the card opens.
So I thought to do it like this....

global sScrollerId
on scrollToLocation
   iphoneControlSet sScrollerId, "hScroll", 0	
   put the left of grc "Marker" - (the width of this stack / 2) - (the width of grc "Marker" / 2) into tNewHScroll
   iphoneControlSet sScrollerId, "hScroll", tNewHScroll
end scrollToLocation

I put this in a button script to test it, and repeated button presses toggle between 2 different scroll values, one of which is correct.
If I put it in an openCard handler, sometimes it works and sometimes it doesn't.

Any idea what I am missing?

Thanks,
- Charles

--
Charles E. Buchwald
http://buchwald.ca


More information about the use-livecode mailing list