上下左右手势

简介: 上下左右手势
-(void)viewDidLoad{
UISwipeGestureRecognizer *recognizer; 
recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];
     [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
    [[self view] addGestureRecognizer:recognizer];
[recognizer release];
    recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];
     [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
    [[self view] addGestureRecognizer:recognizer];
[recognizer release];
recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];
     [recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
    [[self view] addGestureRecognizer:recognizer];
[recognizer release];
UISwipeGestureRecognizer *recognizer;
    recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];
     [recognizer setDirection:(UISwipeGestureRecognizerDirectionDown)];
    [[self view] addGestureRecognizer:recognizer];
[recognizer release];
}
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
if(recognizer.direction==UISwipeGestureRecognizerDirectionDown) {
       NSLog(@"swipe down");
//执行程序
}
if(recognizer.direction==UISwipeGestureRecognizerDirectionUp) {
       NSLog(@"swipe up");
//执行程序
}
if(recognizer.direction==UISwipeGestureRecognizerDirectionLeft) {
       NSLog(@"swipe left");
//执行程序
}
if(recognizer.direction==UISwipeGestureRecognizerDirectionRight) {
       NSLog(@"swipe right");
//执行程序
}
}
相关文章
|
3月前
|
前端开发 JavaScript
鼠标移动淡入淡出Canvas小球效果_特炫
本文通过HTML和JavaScript代码示例展示了如何实现鼠标移动时在Canvas上生成彩色小球并具有淡入淡出效果的动画,涉及Canvas的尺寸调整、小球对象的创建、颜色随机化、透明度变化和动画循环渲染等技术点。
44 1
鼠标移动淡入淡出Canvas小球效果_特炫
|
2月前
ThreeJs的场景实现鼠标拖动旋转控制
这篇文章介绍了如何在Three.js中实现通过鼠标拖动来旋转场景中的模型,并提供了实现这一功能的代码示例。
124 0
|
7月前
滑动工具条
滑动工具条
54 0
|
7月前
鼠标不同方位移入特效
鼠标不同方位移入特效
拼图滑块
拼图滑块
77 1
|
API Android开发 开发者
Gestures(手势)
如果你的手机是Android 4.x的原生Android系统的话,你可能可以在你的手机或者平板上看到谷歌提供的一个Gesture Builder的APP,该应用允许用户以类似于涂鸦的方式绘制一个手写符号,使之对应一个字符串名称!当然,没有这样的手机也没关系,我们有模拟器嘛,自己开个4.0的系统试试就知道了,另外,我们可以到\mmt\sdcard\gestures获取到保存手势的文件!好了,唠唠叨叨那么多,开始讲正题吧!
128 0
使用手势对UIImageView进行缩放、旋转和移动
使用手势对UIImageView进行缩放、旋转和移动
104 0
|
移动开发 前端开发 JavaScript
Canvas之鼠标滑动特效
Canvas之鼠标滑动特效
243 0
Canvas之鼠标滑动特效