ios1基本手势

来源:互联网 发布:java函数参数缺省值 编辑:程序博客网 时间:2024/05/17 22:32
手势的基本定义

/*----------------------各种手势————————*/
    //点击手势
       
 //单击
   
 UITapGestureRecognizer *tap1=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap1Action)];
    [gestureView
 addGestureRecognizer:tap1];
    [tap1
 release];
   
   
 //双击
   
 UITapGestureRecognizer *tap2=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap2Action)];
    tap2.
numberOfTapsRequired=2;
    [gestureView
 addGestureRecognizer:tap2];
    [tap2
 release];
   
   
 //当执行双击时取消单击方法的调用
    [tap1
 requireGestureRecognizerToFail:tap2];
   
   
 //平移手势
   
 UIPanGestureRecognizer *pan=[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)];
    [gestureView
 addGestureRecognizer:pan];
    [pan
 release];
   
     
 //轻扫手势
   
 UISwipeGestureRecognizer *swipe=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeAction:)];
    [gestureView
 addGestureRecognizer:swipe];
    [pan
 requireGestureRecognizerToFail:swipe];
    [swipe
 release];
   
   
 //长按手势
   
 UILongPressGestureRecognizer *longPress=[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
    [gestureView
 addGestureRecognizer:longPress];
    [longPress
 release];
   
   
 //旋转手势
   
 UIRotationGestureRecognizer *rotantion=[[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotantionAction:)];
    [gestureView
 addGestureRecognizer:rotantion];
    [rotantion
 release];
   
   
 //捏合手势
   
 UIPinchGestureRecognizer*pinch=[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchAction:)];
    [gestureView
 addGestureRecognizer:pinch];
    [pinch
 release];

//开启多点触控
   
 self.view.multipleTouchEnabled=YES;
0 0