PDA

View Full Version : How can I detect press and hold on the button and drag and drop




DeathscytheSeph
Apr 27, 2009, 03:53 AM
Now I working on the iphone app and I have 2 question on the ui
1: how can i detect the press and hold on button like apple use on the icon to activate the arrange mode
2: how can i detect the drag and drop on the ui interface eg. i press the table view element and drag my finger on the button to do something other than just press on the table view element

any suggestion thank you^^



jnic
Apr 27, 2009, 04:08 AM
The answer to both is to override the touches methods of UIResponder:

https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIResponder_Class/Reference/Reference.html

DeathscytheSeph
Apr 27, 2009, 04:27 AM
The answer to both is to override the touches methods of UIResponder:

https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIResponder_Class/Reference/Reference.html
Well I think so, but can anyone give me some piece of code for both of that problem for me???

jnic
Apr 27, 2009, 05:21 AM
Well I think so, but can anyone give me some piece of code for both of that problem for me???

We're not here to write your app for you.

1. Start a timer on touch down to perform an action after n seconds, and invalidate it on touch up.
2. All the touches methods give you an set of touches to work with, just record the touch down position and calculate the delta in touches moved.

DeathscytheSeph
Apr 29, 2009, 08:59 PM
We're not here to write your app for you.

1. Start a timer on touch down to perform an action after n seconds, and invalidate it on touch up.
2. All the touches methods give you an set of touches to work with, just record the touch down position and calculate the delta in touches moved.

I know and sorry if i make you upset but I just curious that if I just hold the touch but not move the finger does the touchMove is invoked or not???

Niiro13
Apr 29, 2009, 10:11 PM
I know and sorry if i make you upset but I just curious that if I just hold the touch but not move the finger does the touchMove is invoked or not???

touchesMoved only calls when you move your finger. So if you just touch and don't move, then only touchesBegin is called. Start moving about an inch and like ten or so touchesMoved gets called. Then lift your finger up touchesEnded is called.

touchesMoved is actually called every few pixels you move and not just once if you move it once. So it's not touchesBegin, move an inch touchesMoved, touches Ended. It's more like touchesBegin, move an inch touchesMoved touchesMoved touchesMoved touchesMoved, touchesEnded.

Just so you know how it works ;)

DeathscytheSeph
Apr 30, 2009, 01:58 AM
touchesMoved only calls when you move your finger. So if you just touch and don't move, then only touchesBegin is called. Start moving about an inch and like ten or so touchesMoved gets called. Then lift your finger up touchesEnded is called.

touchesMoved is actually called every few pixels you move and not just once if you move it once. So it's not touchesBegin, move an inch touchesMoved, touches Ended. It's more like touchesBegin, move an inch touchesMoved touchesMoved touchesMoved touchesMoved, touchesEnded.

Just so you know how it works ;)

Thank you all of you :)