View GestureRecognizer

[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]
- (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]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值