[url]http://hi.baidu.com/bunsman/blog/item/1b1930de4e43a74895ee3756.html[/url]
[url]http://hi.baidu.com/%B0%D9ii%D6%AAi%B5%C0/blog/item/04bfba11fb47a2c5f7039ea8.html[/url]
[url]http://blog.csdn.net/pjk1129/article/details/6824810[/url]
[size=medium]UIResponder 响应者链[/size]
[size=medium]长按View[/size]
[size=small]如果双击确定偵測失败才會触发单击
[singleRecognizer requireGestureRecognizerToFail:doubleRecognizer];
@protocol UIGestureRecognizerDelegate <NSObject>
@optional
// called when a gesture recognizer attempts to transition out of UIGestureRecognizerStatePossible. returning NO causes it to transition to UIGestureRecognizerStateFailed
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer;
// called when the recognition of one of gestureRecognizer or otherGestureRecognizer would be blocked by the other
// return YES to allow both to recognize simultaneously. the default implementation returns NO (by default no two gestures can be recognized simultaneously)
//
// note: returning YES is guaranteed to allow simultaneous recognition. returning NO is not guaranteed to prevent simultaneous recognition, as the other gesture's delegate may return YES
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
// called before touchesBegan:withEvent: is called on the gesture recognizer for a new touch. return NO to prevent the gesture recognizer from seeing this touch
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;
@end
[/size]
[size=medium]UITapGestureRecognizer 点击动作
UIPinchGestureRecognizer 捏/掐动作
UIRotationGestureRecognizer 旋转动作
UISwipeGestureRecognizer 轻扫动作
UIPanGestureRecognizer 平移动作
UILongPressGestureRecognizer 长按动作[/size]
[url]http://hi.baidu.com/%B0%D9ii%D6%AAi%B5%C0/blog/item/04bfba11fb47a2c5f7039ea8.html[/url]
[url]http://blog.csdn.net/pjk1129/article/details/6824810[/url]
[size=medium]UIResponder 响应者链[/size]
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
[size=medium]长按View[/size]
UILongPressGestureRecognizer *longPressGR =
[[UILongPressGestureRecognizer alloc] initWithTarget:self
action:@selector(handleLongPress:)];
longPressGR.minimumPressDuration = 0.2;
[self addGestureRecognizer:longPressGR];
[longPressGR release];
- (void)handleLongPress:(UIGestureRecognizer *)gestureRecognizer {
NSLog(@"LONG PRESS");
}
[size=small]如果双击确定偵測失败才會触发单击
[singleRecognizer requireGestureRecognizerToFail:doubleRecognizer];
@protocol UIGestureRecognizerDelegate <NSObject>
@optional
// called when a gesture recognizer attempts to transition out of UIGestureRecognizerStatePossible. returning NO causes it to transition to UIGestureRecognizerStateFailed
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer;
// called when the recognition of one of gestureRecognizer or otherGestureRecognizer would be blocked by the other
// return YES to allow both to recognize simultaneously. the default implementation returns NO (by default no two gestures can be recognized simultaneously)
//
// note: returning YES is guaranteed to allow simultaneous recognition. returning NO is not guaranteed to prevent simultaneous recognition, as the other gesture's delegate may return YES
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
// called before touchesBegan:withEvent: is called on the gesture recognizer for a new touch. return NO to prevent the gesture recognizer from seeing this touch
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;
@end
[/size]
[size=medium]UITapGestureRecognizer 点击动作
UIPinchGestureRecognizer 捏/掐动作
UIRotationGestureRecognizer 旋转动作
UISwipeGestureRecognizer 轻扫动作
UIPanGestureRecognizer 平移动作
UILongPressGestureRecognizer 长按动作[/size]