0

I have a UIScrollView with 10 buttons, each button has its own method. My goal is to activate each button when the user scrolls and the UIButton is "entering" a specific area. What's a good way to accomplish that? (I don't want the UIButton to be pushed. Just hovering on it should activate it)

Example:


button 1

button 2

ooooooo

button 3 <--activated

ooooooo

button 4


Right now button 3 is activated. If the user will scroll down a bit button 2 will be activated.

Segev
  • 19,035
  • 12
  • 80
  • 152
  • This post shows how to get the absolute position for a button inside the scroll view: http://stackoverflow.com/questions/5626411/get-uibutton-inside-an-uiscrollview-absolute-screen-location – Jay Apr 02 '13 at 12:47
  • if the buttons have no purpose other than to trigger an action, would it be easier to define a region on the view, and then if the underlying scrollview moves, check which region of the scrollview is corresponging with the view, and call a method based on the x,y coordinates? – BloonsTowerDefence Apr 02 '13 at 13:28

1 Answers1

0

I'm assuming by activated you mean uicontrolstate of the button being enabled or not. The most straight forward way I can think to do this is by doing something similar to BloonsTowerDefence and look at the uiscrollviews contentoffset and at various ranges you will examine the contentoffset and disable all the rest of the buttons and enable the button you would like to be enabled at that range.

Ben Coffman
  • 1,750
  • 1
  • 18
  • 26