Hi,
When I use touchesBegan, touchesMoved, and touchesEnded on UIView, I've found that after the first touch, the Began and Ended methods are only called when one of the touches moves. For example:
1. I put one finger down - touchesBegan is called.
2. I put another finger down without moving it - nothing is called.
3. I move any of the fingers - touchesBegan is called, then touchesMoved.
4. I remove one finger - nothing is called.
5. I move the remaining finger - touchesEnded is called, then touchesMoved.
6. I remove the last finger - touchesEnded is called.
But in some apps, especially games, touchesBegan and touchesEnded are called for additional touches right when they begin and end, not after they move. How can I get this kind of functionality?
Thanks!
Hi,
When I use touchesBegan, touchesMoved, and touchesEnded on UIView, I've found that after the first touch, the Began and Ended methods are only called when one of the touches moves. For example:
1. I put one finger down - touchesBegan is called.
2. I put another finger down without moving it - nothing is called.
3. I move any of the fingers - touchesBegan is called, then touchesMoved.
4. I remove one finger - nothing is called.
5. I move the remaining finger - touchesEnded is called, then touchesMoved.
6. I remove the last finger - touchesEnded is called.
But in some apps, especially games, touchesBegan and touchesEnded are called for additional touches right when they begin and end, not after they move. How can I get this kind of functionality?
Thanks!
You have to enable multiple touches for the view(s). Set the multipleTouchEnabled on the view(s) to TRUE. It's false by default.
BTW, you should try gesture recognizers. They make handling touch, drag, pan, pinch, rotate, and other gestures a WHOLE lot easier. Do a search on "touches" and look for the sample project of that name. Run the gesture recognizer version of that sample project.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.