UITouch details, uitouch
The UITouch object is used to position, size, motion, and the intensity of a specific event on the screen with a finger. The intensity of touch is available on devices that support 3D touch on iOS 9. You can use the UIEvent object to pass to the responder object for access. A UITouch object includes the accessors:
View or Window that causes touch.
@ Property (nullable, nonatomic, readonly, strong) UIWindow * window
@ Property (nullable, nonatomic, readonly, strong) UIView * view
Coordinates of the position of the touch in the view or Window.
-(CGPoint) locationInView :( nullable UIView *) view
The radius of the touch.
@ Property (nonatomic, readonly) CGFloat altitudeAngle
Touch strength (support for iOS9.0 or above)
@ Property (nonatomic, readonly) CGFloat force
The UITouch object also contains a timestamp indicating the time when the touch occurred. An integer indicates the number of times the user clicks the screen. In the touch stage, it describes whether the touch starts, moves, or ends in a constant form, or whether the system is untouched.
A touch object always contains a touch sequence. When processing an event, a touch object is never retained. If you need to retain touch information from one touch stage to another, copy the information.
The gestureRecognizers attribute of the touch contains the currently processed touch gesture recognition. Each gesture reader is an instance of the UIGestureRecognizer subclass.
Below is an instance
I define two UIVIEW instance objects in ViewController.
@interface ViewController : UIViewController@property (nonatomic, strong) UIView *viewA;@property (nonatomic, strong) UIView *viewB;@end
Then
-(Void) viewDidLoad {
[Super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
Self. viewA = [[UIView alloc] initWithFrame: CGRectMake (10, 30, 48, 48)];
Self. viewA. backgroundColor = [UIColor blackColor];
[Self. view addSubview: self. viewA];
Self. viewB = [[UIView alloc] initWithFrame: CGRectMake (10,100, 48, 48)];
Self. viewB. backgroundColor = [UIColor redColor];
[Self. view addSubview: self. viewB];
NSLog (@ "viewA: % @ \ n viewB: % @ \ n window: % @", self. viewA, self. viewB, [[[UIApplication sharedApplication] windows] objectAtIndex: 0]);
}
-(Void) didReceiveMemoryWarning {
[Super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(Void) touchesBegan :( NSSet <UITouch *> *) touches withEvent :( UIEvent *) event
{
// NSLog (@ "% @", [touches anyObject]);
UITouch * touctObj = [touches anyObject];
NSLog (@ "touch: % @ \ n view: % @ \ n window: % @", touctObj, [touctObj view], [touctObj window]);
}
We can see that the view is neither viewa nor viewb. It is the view of the controller. window is the window of the application.
In short, the UITouch object contains some touch information. View or window that causes touch.