Cocoa Touch - Timing button presses - iphone

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.

Related

Swift: Custom Slider (Slide To Unlock style)

I am trying to implement a slider in the known slide to unlock style from older iphones to perform an action inside my swift app. The Slider should change background color and change the text inside while dragging. When the user drags til the end, the thumbView should stick to the right side and wait for a confirmation (some event) coming in to finally present a new view.
The slider should look something like this:
First state
Second state while dragging
Third state after releasing
I have found a few things on the internet but nothing that comes close to what I want to do. How would I go about doing this? My guess would be a combination of views with drag events but I feel like there must be an easier way. Any Ideas?
Maybe a UISlider with a transparent track on a rectangle view with your text and color. You can set your image as the UISlider's thumb and receive events as the value changes and when the user touches and releases it.
You can use that to for example, animate the thumb back to the start when the user releases on any place except the end of the track. Also, you can set the slider's value from 0 to 1 and use it to calculate the color, so it changes smoothly.
When the user releases on the end of the track, you activate the activity indicator and start your process to present the next view....
Even though this is a possibility, I think I'd try doing a custom control using a pan gesture. It'd give you more control and you could for example choose how the thumb image animates when going back to the start on release.... I dont' think you can do that with UISlider's setValue(animated:).

How to enable multi touch on click buttons?

I couldn't find an answer online. When I hold my phone with my hand, the palm of my hand touches the screen's bottom corner and it prevents/blocks any future clicks on buttons with my fingers on the screen. I need to enable multi-touch for buttons but not sure how to do it. I use buttons and (onClick component) but they don't work when I hold my phone with my palm. I need to tell the app- ignore previous clicks and count only the latest click
It's possible only via IPointerClick and other IPointer...Handler.
Please refer to UnityEngine.EventSystems namespace.

Possible to count the number of touches in 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

Event for finger being moved off button but not lifted in objective C (iphone)

Is there an event which will get whether the user has moved his finger outside of the button?
Kind of like TouchUpOutside except without the "up" bit.
Like how the iphone keyboard, the letter gets smaller (back to normal) as you move your finger of the letter.
Use UIControlEventTouchDragExit. You can attach a target and action to the control for that particular control event.

Another drag and drop question on iPhone

I tried to find an easy solution for the following.
I have a main view which holds a tile. I want to drag and drop it over a UITableView. I could program the pick and drag already with UIGestureRecognizer.
Now my problem is how can I detect within the table view that there is an item going to be dragged above it. For instance I want to highlight the given row when the tile is moved above it.
I tried to add the touchesMoved/Began/Ended events to the viewCell. They does not get fires when I am dragging the tile over it (in other words the tile is hiding a portion of the viewCell under my finger). They get fired when there is no tile dragged above.
Is there an effective hittest method for that?
Thanks.
There are a whole bunch of UI issues here that should be addressed.
In general, Drag and drop on the iPhone is a BAD idea. It's very hard to do, and getting feedback is going to be problematic, because your finger will be obstructing the drag operation
using the table's selected cell to indicate 'dropability' may get you rejected by the app store reviewers; it's to indicate "I've selected this cell", not "I'll drop something onto it"
That said, you'll probably want to manage all your touch events in the 'source' view, and send the table messages from there, rather than trying to juggle messages around. Once your -touchesBegan:withEvent: has been called in one view, all subsequent -touchesMoved:withEvent: and -touchesEnded:withEvent: will be sent to that view for the life-cycle of that touch; forwarding them around will confuse the heck out of everyone involved.