- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;缓存
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;ui
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;atom
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;orm
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event;对象
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event;排序
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event;继承
- (void)remoteControlReceivedWithEvent:(UIEvent *)event;队列
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event事件
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)eventip
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
提示:touches中存放的都是UITouch对象
@property(nonatomic,readonly,retain) UIWindow *window;
@property(nonatomic,readonly,retain) UIView *view;
@property(nonatomic,readonly) NSUInteger tapCount;
@property(nonatomic,readonly) NSTimeInterval timestamp;
@property(nonatomic,readonly) UITouchPhase phase;
@property(nonatomic,readonly) UIEventType type;
@property(nonatomic,readonly) UIEventSubtype subtype;
@property(nonatomic,readonly) NSTimeInterval timestamp;
UIApplication -> UIWindow -> 白色 -> 绿色
UIApplication -> UIWindow -> 白色 -> 橙色 -> 蓝色
UIApplication -> UIWindow -> 白色 -> 橙色 -> 蓝色 -> 黄色
userInteractionEnabled = NO
hidden = YES
alpha = 0.0 ~ 0.01
4. 若是子视图的位置超出了父视图的有效范围, 那么子视图也是没法与用户交互的, 即便设置了父视图的 clipsToBounds = NO, 能够看懂, 可是也是没法与用户交互的
提示:UIImageView的userInteractionEnabled默认就是NO,所以UIImageView以及它的子控件默认是不能接收触摸事件的
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
// 连续敲击2次
tap.numberOfTapsRequired = 2;
// 须要2根手指一块儿敲击
tap.numberOfTouchesRequired = 2;
[self.iconView addGestureRecognizer:tap];
[tap addTarget:self action:@selector(tapIconView:)];
typedef NS_ENUM(NSInteger, UIGestureRecognizerState) {
// 没有触摸事件发生,全部手势识别的默认状态
UIGestureRecognizerStatePossible,
// 一个手势已经开始但还没有改变或者完成时
UIGestureRecognizerStateBegan,
// 手势状态改变
UIGestureRecognizerStateChanged,
// 手势完成
UIGestureRecognizerStateEnded,
// 手势取消,恢复至Possible状态
UIGestureRecognizerStateCancelled,
// 手势失败,恢复至Possible状态
UIGestureRecognizerStateFailed,
// 识别到手势识别
UIGestureRecognizerStateRecognized = UIGestureRecognizerStateEnded
};