Is there a way to get the UITouch
objects associated with a gesture? UIGestureRecognizer
doesn't seem to have any methods for this.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
If it is just the location you are interested in, you do not have to subclass, you will be notified of location changes of the tap from the UIGestureRecognizer.
Initialize with target:
Handle UIGestureRecognizerStateChanged to get location changes:
Jay's right... you'll want a subclass. Try this one for size, it's from one of my projects. In DragGestureRecognizer.h:
And in DragGestureRecognizer.m:
Of course, you'll need to implement the
method in your delegate -- for example:
Simple and fast:
Where recognizer is your
UIGestureRecognizer
Here is a method to get a long press added to an arbitrary UIView.
This lets you run longpress on any number of UIViews. In this example I restrict access to the UIView method through tags but you could use isKindOfClass as well.
(From what I found you have to use touchesMoved for LongPress because touchesBegan fires before the LongPress becomes active)
subclass - .h
subclass - .m
viewcontroller - .h
viewcontroller - .m
If you only need to find out the location of the gesture, you can call either locationInView: or locationOfTouch:inView: on the UIGestureRecognizer object. However if you want to do anything else, then you'll need to subclass.
If you're writing your own UIGestureRecognizer you can get the touch objects overriding:
or the equivalent moved, ended or canceled
The Apple docs has lots of info on subclassing