- (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
};