触摸事件

//*****添加手势,一定要打开用户交互,否则就不会响应

    imgv.userInteractionEnabled=YES;

    //创建一个点击手势

    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapChangeAction:)];

    //把创建的单击手势给图片视图

    [imgv addGestureRecognizer:tap];

   

    //创建一个旋转的手势对象

    UIRotationGestureRecognizer*rotation=[[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(rotationChangeAction:)];

    //添加手势到imgv

    [imgv addGestureRecognizer:rotation];

    //创建捏合手势

    UIPinchGestureRecognizer *pinch=[[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchChangeAction:)];

    //添加手势

    [imgv addGestureRecognizer:pinch];

    //创建长按手势

    UILongPressGestureRecognizer *longpress=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressAction:)];

    [imgv addGestureRecognizer:longpress];

   

    //创建扫动手势

    UISwipeGestureRecognizer *swipe=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeChangeAction:)];

    swipe.direction=UISwipeGestureRecognizerDirectionLeft;

    [imgv addGestureRecognizer:swipe];

原文地址:https://www.cnblogs.com/xiamo123/p/4763327.html