(转)iphone上下左右手势判断代码

  1. - (void)viewDidLoad {
  2. UISwipeGestureRecognizer *recognizer;
  3. recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:selfaction:@selector(handleSwipeFrom:)];
  4. [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
  5. [[self view] addGestureRecognizer:recognizer];
  6. [recognizer release];
  7. recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:selfaction:@selector(handleSwipeFrom:)];
  8. [recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
  9. [[self view] addGestureRecognizer:recognizer];
  10. [recognizer release];
  11. recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:selfaction:@selector(handleSwipeFrom:)];
  12. [recognizer setDirection:(UISwipeGestureRecognizerDirectionDown)];
  13. [[self view] addGestureRecognizer:recognizer];
  14. [recognizer release];
  15. recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:selfaction:@selector(handleSwipeFrom:)];
  16. [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
  17. [[self view] addGestureRecognizer:recognizer];
  18. [recognizer release];
  19. [super viewDidLoad];
  20. }
  21. -(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
  22. NSLog(@"Swipe received.");
  23. if (recognizer.direction==UISwipeGestureRecognizerDirectionDown) {
  24. NSLog(@"swipe down");
  25. //执行程序
  26. }
  27. if (recognizer.direction==UISwipeGestureRecognizerDirectionUp) {
  28. NSLog(@"swipe up");
  29. //执行程序
  30. }
  31. if (recognizer.direction==UISwipeGestureRecognizerDirectionLeft) {
  32. NSLog(@"swipe left");
  33. //执行程序
  34. }
  35. if (recognizer.direction==UISwipeGestureRecognizerDirectionRight) {
  36. NSLog(@"swipe right");
  37. //执行程序
  38. }
  39. }
时间: 2024-07-30 01:47:13

(转)iphone上下左右手势判断代码的相关文章

android 上下左右手势判断 根据别人的改的

GestureUtils.java package com.gesture; import android.content.Context;import android.util.DisplayMetrics;import android.view.WindowManager; public class GestureUtils { //获取屏幕的大小 public static Screen getScreenPix(Context context) { DisplayMetrics dm =

常用JS图片滚动(无缝、平滑、上下左右滚动)代码大全

常用JS图片滚动(无缝.平滑.上下左右滚动)代码大全 今天刚网上看的 不多说直接帖代码---- <head><-----></head><body> <!--向下滚动代码开始--><div id="colee" style="overflow:hidden;height:253px;width:410px;"><div id="colee1"><p>&

iPhone 屏幕适配判断 和 iOS系统版本判断

? 1 2 3 4 5 6 7 8 9 if([[[UIDevicecurrentDevice]systemVersion]floatValue]>=7.0) {     // iOS7.0及以上版本系统适配 } if([UIScreen mainScreen].bounds.size.height == 568) {     // iPhone 屏幕适配 } 可以写成宏定义放在pch文件中, ? 1 2 3 4 // 判断是否为iPhone5 #define iPhone5 ([UIScree

ios开发--旋转、移动、缩放手势实例代码

代码如下: C代码   // 添加所有的手势 - (void) addGestureRecognizerToView:(UIView *)view { // 旋转手势 UIRotationGestureRecognizer *rotationGestureRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotateView:)]; [view addGestureReco

js无刷新上传图片,服务端有生成缩略图,剪切图片,iphone图片旋转判断功能

html: <form action="<{:AppLink('circle/uploadimg')}>" id="imageform" method="post" enctype="multipart/form-data">     <input name="photoimg" type="file" id="xwzx_f" style

iphone编程,使用代码结束程序

(ios 4环境) 1.使用代码可以结束自己只有一种方式,而且apple不建议这样用,就是调用exit()函数.在2.0以前uiapplication类中有一个方法可以调用,但是现在已经没有了,而且如果你强制使用2.0以前的编译环境,apple会拒绝你发布这个程序到app store. 2.用户按下home键后,程序转入后台运行. 3.连续按两次home键后,在iphone屏幕下面会出现一个程序列表,这个列表,我原先以为是转入后台运行的程序列表,通过试验结果看到,我错了,这个只是最近使用的程序列

判断iPhone和iPad 判断设备版本

//判断iPhone和iPad #define IS_IPHONE (!IS_IPAD) #define IS_IPAD (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone) //判断设备版本 #define IS_IOS6_LAGACY floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1 #define IS_IOS7 floor(NSFounda

区分上下左右手势cocos2dx

直接上方法:我是根据触摸开始点和结束点做的方向判断 ,有更好方法的小伙伴请留言给我 ,多谢 void GameLayer::ccTouchEnded(CCTouch *touch,CCEvent *event){ if (openTouch) { CCPoint touchEndP=touch->getLocation(); double d=Distance(touchStartP,touchEndP); CCLOG("两点的距离 :%f",d ); //如果触摸距离超过20判

检测js代码是否已加载的判断代码

该方法不局限于jQuery的检测,对与任何Javascript变量或函数都是通用的. 当前网页加载jQuery后,jQuery()或$()函数将会被定义,所以检测jQuery是否已经加载存在以下2种方法:方法1:代码如下: 1 if (jQuery) { 2 // jQuery 已加载 3 } else { 4 // jQuery 未加载 5 } 方法2:代码如下: 1 if (typeof jQuery == 'undefined') { 2 // jQuery 未加载 3 } else {