上下左右手势

简介: 上下左右手势
-(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");
//执行程序
}
}
相关文章
|
1月前
ThreeJs的场景实现鼠标拖动旋转控制
这篇文章介绍了如何在Three.js中实现通过鼠标拖动来旋转场景中的模型,并提供了实现这一功能的代码示例。
70 0
|
6月前
滑动工具条
滑动工具条
42 0
|
6月前
鼠标不同方位移入特效
鼠标不同方位移入特效
|
11月前
水波纹按钮动画
水波纹按钮动画
46 0
水波纹按钮动画
|
API Android开发 开发者
Gestures(手势)
如果你的手机是Android 4.x的原生Android系统的话,你可能可以在你的手机或者平板上看到谷歌提供的一个Gesture Builder的APP,该应用允许用户以类似于涂鸦的方式绘制一个手写符号,使之对应一个字符串名称!当然,没有这样的手机也没关系,我们有模拟器嘛,自己开个4.0的系统试试就知道了,另外,我们可以到\mmt\sdcard\gestures获取到保存手势的文件!好了,唠唠叨叨那么多,开始讲正题吧!
115 0
|
移动开发 前端开发 JavaScript
Canvas之鼠标滑动特效
Canvas之鼠标滑动特效
234 0
Canvas之鼠标滑动特效
鼠标拖拽翻页效果
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/w178191520/article/details/84192737 ...
995 0
|
Android开发
Android 自定义控件之SlidingMenuVertical顶部悬浮(垂直折叠抽屉,有滑动渐变回调,可自行添加渐变动画)
顶部悬浮(垂直折叠抽屉,有滑动渐变回调,可自行添加渐变动画)
2068 0