(1)效果
(2)代码
http://download.csdn.net/detail/wsb200514/8261001
(3)总结
——先根据所需创建不同类型的手势识别,比如:
UITapGestureRecognizer UISwipeGestureRecognizer UIPinchGestureRecognizer UIRotateGestureRecognizer UIPanGestureRecognizer
——然后把这些手势对象利用addGestureRecognizer方法添加到需要的那个对象中去,如:
[self.imgView addGestureRecognizer:swipe];
——当然,这些手势都可以利用addTarget增加一些事件检测,如:
UIPinchGestureRecognizer *pinch=[[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchView:)];
——还有,手势识别还有一些比较常用的代理方法,如以下方法是否允许多个手势同时起作用:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{ return YES; }
时间: 2024-10-03 19:18:48