views:

266

answers:

2

I am trying to have a button move around the screen and still be clickable. I have it moving around the screen correctly, but the odd thing is that I can't click the button until the final second of the animation. The button is still moving and yet after a certain threshold I can click it. Any idea what is happening? Any idea for some other way I can do what I want? Thanks for any help.

A: 

Without any detailed information, I can only assume certain aspects of the problem. My assumption is that you've created a dynamic UIButton and set it to the view, which is completely clickable when it's not moving on the screen. However, when you animate the button as a UIView, the button is no longer clickable. From my understanding, this is not possible.

Ben.Vineyard
I went into Interface Builder and dragged a rounded rect button onto the View. In my view controller class I have an IBOutlet UIButton that is correctly linked in IB. my code for animating the button is a simple [UIView beginAnimation...] set of lines. I set the duration to 5 seconds. then the "changes" to be made is the button center is being set to some other place on the screen. If I comment out the animation the button is clickable and fine and stationary and the function linked to the touchUpInside works. If the animation goes, it will not turn blue or call the function until it stops.
Robert
A: 

I believe the button is moved to the final animation position when the animation starts, however it is not displayed there until the animation is done. While moving you only see a projection of the image of it, not really the actual button. I think if you could periodically log the frame value of the button during the animation you could see this (hmmm, I'll have to try that in my color picker).

Perhaps you can move the button a little at a time in many animations instead of one long move?

EDIT: I tried this in a program I'm working on, logged the origin for an object being animated. It has the final origin value throughout the animation:

2010-05-04 20:41:08.914 beginAnimations: origin=175 197
2010-05-04 20:41:08.915 commitAnimations: origin= 79 333
2010-05-04 20:41:08.964 -[ColorPickerVC showSlidingColorOrigin:]  79 333
2010-05-04 20:41:09.064 -[ColorPickerVC showSlidingColorOrigin:]  79 333
2010-05-04 20:41:09.164 -[ColorPickerVC showSlidingColorOrigin:]  79 333
2010-05-04 20:41:09.264 -[ColorPickerVC showSlidingColorOrigin:]  79 333
2010-05-04 20:41:09.364 -[ColorPickerVC showSlidingColorOrigin:]  79 333
2010-05-04 20:41:09.464 -[ColorPickerVC showSlidingColorOrigin:]  79 333
2010-05-04 20:41:09.577 annimationDone: origin= 79 333
progrmr
I am thinking this as well. I have decided to instead just use an NSTimer with a function that will update the buttons center x and y. Hopefully that works better but I think it will, thanks for the help to all.
Robert
Why does it need to be usable while it's moving? Unless it moves very slowly it's kind of hard to hit a moving target anyway.
progrmr