iOS 开发
的有关信息介绍如下:iOS 系统在 3.2 以后,提供了一些常用的手势(UIGestureRecognizer 的子类),开发者可以直接使用他们进行手势操作。UIPanGestureRecognizer(拖动)UIPinchGestureRecognizer(捏合---放缩图片)UIRotationGestureRecognizer(旋转)UITapGestureRecognizer(点按)UILongPressGestureRecognizer(长按)UISwipeGestureRecognizer(轻扫 滑动)
1.======"捏合手势"(放缩图片)======键盘快捷键: Alt + 鼠标右键 Mac: option + 触摸板右键
2.=========添加"点击手势"=======通过鼠标右键点击
======滑动手势/ 轻扫手势=======//解决在图片上滑动时拖动手势和轻扫手势的冲突 [panGesture requireGestureRecognizerToFail:swipeGestureToRight]; [panGesture requireGestureRecognizerToFail:swipeGestureToLeft];
=======拖动手势======//解决在图片上滑动时拖动手势和轻扫手势的冲突 [panGesture requireGestureRecognizerToFail:swipeGestureToRight]; [panGesture requireGestureRecognizerToFail:swipeGestureToLeft];//解决拖动和长按手势之间的冲突 [longPressGesture requireGestureRecognizerToFail:panGesture];//解决在图片上滑动时拖动手势和轻扫手势的冲突 [panGesture requireGestureRecognizerToFail:swipeGestureToRight]; [panGesture requireGestureRecognizerToFail:swipeGestureToLeft];//默认为向右轻扫swipeGestureToRight.direction=UISwipeGestureRecognizerDirectionRight;
=======旋转======键盘快捷键: Alt + 鼠标右键
=====长按======//解决拖动和长按手势之间的冲突 [longPressGesture requireGestureRecognizerToFail:panGesture];
=====摇晃======在模拟器中运行时,可以通过[Hardware]-[Shake Gesture](或者command+shift+z)
#pragma mark 手势代理方法-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{ //NSLog(@"%i,%i",gestureRecognizer.view.tag,otherGestureRecognizer.view.tag); //注意,这里控制只有在UIImageView中才能向下传播,其他情况不允许 if ([otherGestureRecognizer.view isKindOfClass:[UIImageView class]]) { return YES; } return NO;}