I'm overriding the touches methods in a UIView for a piano app.
If I touch with one finger the iPhone or iPad I get -as expected- the touchesBegan callabck. And if I touch with a second finger I get that event in the touchesMoved callback. This is all fine, BUT I get the second (and third etc) callback ONLY if the first finger moves while I touch with the second one.
For a piano app this is a problem since I need to be able to touch really quickly.
Does anybody know a workarround for this? Is there an alternative than using touchesBegan/Moved/Ended methods?
Did you enable multitouch (setMultipleTouchEnabled:YES) for that UIView?
Related
Implementing a sort of 'distress call' button which should work as following:
User starts application and covers a screen with a palm of a hand
Some time passes, user may introduce additional touches during that time or remove some of the existing (but not all of them), location/shape of touches may change
When user releases a hand (i.e. removes last touch) a distress signal is emitted by the app
Basically, the app should register two events: (1) a screen is touched (2) all touched are released
I'm trying to use touchesBegan/touchesEnded methods and those work for small area touches (fingertips) but on touching screen with a full palm or even only palm edge a touchesCancelled gets triggered immediately while hand is still on the screen. Obviously no other events are emitted upon hand release afterwards.
I tried subclassing UIWindow and UIApplication and overriding sendEvent in those but got no additional info - large area touches are triggering touch begin and immediately touch cancel, releasing hand afterwards emits nothing. In some cases large area touches fire no events at all, not even the touchesBegan. Basically, iOS doesn't let me work with a very basic scenario - detecting just the fact of screen touch/release.
Is there any way to query the screen touch state directly and not work with responder chain? Or suppress the cancellation event from firing? Or maybe I'm missing something?
Unfortunately, as of right now, no solution exists
I'm using the new UIPreviewInteraction API and want to know the location where the user lifts up his finger.
Basically the flow that I want to create is:
User 3D touches on something.
Bubbles appear around his finger.
User slides his finger on top of one of them.
Lifts his finger and the app registers his selection.
The UIPreviewInteraction API doesn't have a reference to the UITouch that initiated the interaction.
Is there another way to get it?
Alright, turns out I was going about it the wrong way.
I was trying to receive touch updates in the previewInteraction:didUpdatePreviewTransition:ended: method
But there you'll only receive updates until the 'peek' is happening. After it ends, you no longer receive any updates.
However, if you override the previewInteraction:didUpdateCommitTransition:ended: method you'll continue receiving touch location updates there using this code:
CGPoint touchPoint = [previewInteraction locationInCoordinateSpace:previewInteractionView];
You can find sample code from the Apple WWDC video here
I wonder if I can detect continuously changing pressure of user input on iPhone 6s.
With simple touch it's obvious, from the UIResponder you can hook into touchesBegan and TouchesMoved and you'll have the coordinates every time when the user touches the screen and when moves his/her finger, you can have the current position on every update.
However, I'm not sure how the new :force property works. If you read the "force" in touchesBegan, wouldn't you get some minimal pressure value that was detected at the initiation of the touch?
Is there a way to get update on the force value as it changes, just like the touchesMoved? Maybe there is a method like "forceChanged"?
From the iOS 9.1 Release Notes
On 3D Touch capable devices, touch pressure changes cause touchesMoved: to be called.
Apps should be prepared to receive touch move events with no change in the x/y coordinates.
This means that a touchesMoved: callback either indicates a continuous change in force or location or both!
Hopefully this information will one day make it into the UITouch documentation.
In iOS is there any way to tell, when the touch ends, if it ended by sliding off the screen or if the user lifted his finger?
I don't know why, but I expected the touch to be cancelled when this happened, but it is not.
Thanks.
This is standard iOS behavior, you may see it in any Apple's app.
You may check if touch ended at the end of screen and treat it as "cancel sliding", but user might be wanting to slide this far.
My advice is accept it, because, as I said before, it's standard behavior, and Apple tells us to stick to it - users expect standard behavior.
Only through deduction. If the finger was moving towards the edge of the screen and then the touch ends near that edge, you can be relatively certain that the finger indeed slid off the screen. If it wasn't moving immediately before the touch ended, the user probably just lifted their finger.
UPDATE
I'm looking for the best way to detect more than one finger on a particular view at time in this case the view is UITextview. I'm not detecting taps or pinching, just the fact that more than one touch is happening. In this case, i set textview.multipleTouchEnabled=NO and then i didn't set gesture anywhere. And i didn't set the zoom in UITextView. And i didn't override some of touches method in that controller.
the problem is, when i touch my app on the device using a touch like pinching, or touch use more than one finger, the app got crashed and no error log in the debugger console. I try to debug this app, but i dont know what i'm looking for.
UPDATE 2
i was wrong about the object that get user touch, i was thought that the object is UITextview, but UIWebview. So, this problem is happen when i touch UIWebview with 2 fingers. I have forwarded the touches event using this suggestion. But i still confuse, how to clear up this crash on my app.
Can somebody help me??
Thank You
Regard,
Risma
Check that text view zoom level is set by default it's min and max zoom is 1.
In pinch gesture you have to set scale factor.