Possible to count the number of touches in iphone? - iphone

I want to count the number of touches in one second. So, if three touches were detected in one second do this, if 5 detected to that. I wanted to know if you can do that in touchesBegan.
All I want to do is execute different methods according to how fast the user touches the screen.
Thanks for your help.

I would suggest you use a UITapGestureRecognizer and then handle the taps accordingly depending on how many were detected. It is capable of detecting individual taps as well as how many fingers were set down.
Here's the documentation on it:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UITapGestureRecognizer_Class/Reference/Reference.html

Related

drawing a line from gesture between 2 buttons

I am beginner for interactions on iphone. I have 3 buttons, one on the left, and the 2 other ones on the right. I would like to push the left button with finger and display a line real time stretching with my finger moving on screen that goes to the other button I am going to go to on the right - and then I reach the button on the right and release my finger the line stays on screen.
Where should I start in the manual to understand how to do something like this?
- please don't say page 1 ;-)
thanks for all the pointers so I can learn and write the code myself
Cheers,
geebee
Wow, uh, you're jumping right into the deep end.
First, the answer to your question is ... check out the Sample Code at developer.apple.com. By playing with those sample projects, and running them in the debugger, and reading that code, you can learn a whole lot about what you're trying to do.
Using those samples as your tutorial, refer to specific information in the reference docs also available at developer.apple.com. There are specific docs on the classes you'll be using (e.g. UIButton Class Reference), and there are high level guides that talk about different areas, like the Event Handling Guide for iOS, and Drawing and Printing Guide for iOS.
Here are some of the issues you're going to face, and some of the areas that you should read up on:
UIButtons are going to respond to your touch and won't allow any other view to receive that touch without some special handling in your code.
Check out samples that deal with UITouch events, Quartz 2D drawing, creating custom controls
Try doing this without any buttons first, that's fairly simple. Just figure out how to detect a TouchDownInside event, track the finger movement across the screen, and detect a TouchUpInside event, all in a normal UIView. (There may be a sample for this.)

Position both the safari "touches" from a gesture event?

I want to get the position (relative or otherwise) of the two fingers/touches inside a gesture event (gesturestart, gesturechange, gestureend) on mobile Safari (iOS: iPad/iPhone). I know that the gesture* events don't actually provide this in the event args but i thought there might be a 'trick' to getting this info. It would be great to get the coords of the fingers while tracking a gesture (eg. scaling and moving an object in the same gesture).
Can this be done?
It turns out that this information is not directly available via the 'gesture' events. The touch events are the key and i was able to get the touches collection and use the first two touches to derive a delta/midpoint of the two sets of coords. This seems to work.
There are three arrays in the returned event object for touch event:
touches
targetTouches
changedTouches
I can't remember where I originally found this info, but a quick Google search brings up http://www.sitepen.com/blog/2008/07/10/touching-and-gesturing-on-the-iphone/
Got it! https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html Down at "Handling Multi-Touch Events"

Cocoa Touch - Timing button presses

I'm making a reaction type game and I needed some help implementing a way to define who touched it first.
So I can compare and know who is the winner and award points correctly. I have no idea how im gonna implement this...
Any Ideas?
If you have multiple buttons on your screen, the easiest way is probably to keep track of all the button presses (UITouch events) you get in the order you receive them. Once you get all the button presses you're expecting, go through the ordered list of presses and assign points as necessary.

iPhone -- possible to tell the difference between a fingertip and a whole fingerpad?

Is it possible to detect exactly how much finger is in contact with the screen? Say I wanted to make a fingerprinting app, how would I detect the outline of a person's fingeR?
No, the UITouch system does a lot of processing to determine a single point location for each touch given the larger touched area. This is meant to aid the user as there can be some difference between where one thinks he is touching and where the screen is actually touched.

UISlider Multiple Touch Lag

I'm developing an game which has a component based on UISliders. The player must slide them from left to right one at a time, and on occasion two at a time. The problem lies in the double slides. When sliding two UISliders at a time, the sliders lag behind the player's touches, and often create noticeable lag in the game (this was tested on iPhone 3GS). I'm assuming this is due to the OS trying to recognize a multitouch gesture, but I'm not certain.
My question is what can I do to alleviate the lag? It must be possible because there are drawing apps out there that use up to 5 fingers without much lag, so 2 should be cake.
Let me guess, are you redrawing the screen in the event handler for the UISlider? In which case you are trying to do it redundantly a lot of the time. Instead of redrawing in the event handler, record the change in your view controller. Then you have a timer set up and in that you check to see if your variable is set and if so redraw then.