- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UIImageView *p_w_picpathView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 30, 280, 430)];
    p_w_picpathView.p_w_picpath = [UIImage p_w_picpathNamed:@"2.jpg"];
    //将用户交互打开,,切记  只有两个UIImage  和UILabel  都要打开交互
    [p_w_picpathView setUserInteractionEnabled:YES];
    [self.view addSubview:p_w_picpathView];
    [p_w_picpathView release];
    
    /*
    //手势使用  看继承关系,,,有没有自己的初始化方法
    //1.点击
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    //1.1设置要点击几次才会触发方法
    tap.numberOfTapsRequired = 3;
    //1.2需要几个手指点击
    tap.numberOfTouchesRequired = 2;
    //1.3将手势添加到p_w_picpathView上
    [p_w_picpathView addGestureRecognizer:tap];
    [tap release];
    */
    
    /*
    //2.长按
    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressAction:)];
    //1.1判定为长按手势需要的最短时间
    longPress.minimumPressDuration = 3;
    //1.2判定为长按的过程中,允许用户手指移动的距离
    longPress.allowableMovement = 300;
    [p_w_picpathView addGestureRecognizer:longPress];
    [longPress release];
    */
    
    /*
    //3.旋转
    UIRotationGestureRecognizer *rotation = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationAction:)];
    [p_w_picpathView addGestureRecognizer:rotation];
    [rotation release];
     */
    
    /*
    //4.捏合
    UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchAction:)];
    [p_w_picpathView addGestureRecognizer:pinch];
    [pinch release];
    */
    /*
    //5.拖拽
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)];
    [p_w_picpathView addGestureRecognizer:pan];
    [pan release];
    */
    
    //6.清扫
    UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(awipeAction:)];
    [p_w_picpathView addGestureRecognizer:swipe];
    //清扫的方向,向左  (如果要四个方向,就只能加四个手势)
    swipe.direction = UISwipeGestureRecognizerDirectionLeft;
    [swipe release];
    
    
    
}
//6.清扫
- (void)awipeAction:(UISwipeGestureRecognizer *)awipe
{
    if (awipe.direction == UISwipeGestureRecognizerDirectionLeft) {
        NSLog(@"向左");
    }
    NSLog(@"清扫");
}
//5.拖拽
- (void)panAction:(UIPanGestureRecognizer *)pan
{
    UIImageView *view = (UIImageView *)pan.view;
    //获得手势经过的点
    CGPoint p = [pan translationInView:view];
    //对视图的transform属性改变
    view.transform = CGAffineTransformTranslate(view.transform, p.x, p.y);
    //对拖拽的位置进行初始化
    [pan setTranslation:CGPointZero inView:view];
//    NSLog(@"拖拽");
}
//4.捏合
-(void)pinchAction:(UIPinchGestureRecognizer *)pinch
{
    //试图的TRanform属性
    UIImageView *view = (UIImageView *)pinch.view;
    //捏合的x,y的方向
//    view.transform = CGAffineTransformMakeScale(pinch.scale, pinch.scale); //捏合后重置
    //在原有的基础上在捏合
    view.transform = CGAffineTransformScale(view.transform, pinch.scale, pinch.scale);
    pinch.scale = 1;
    NSLog(@"捏合");
}
//3.旋转
- (void)rotationAction:(UIRotationGestureRecognizer *)rotation
{
    //视图的transform属性---变形
    //1.获得添加手势的视图
    UIImageView *p_w_picpathView = (UIImageView *)rotation.view;
    //2.旋转的角度  (属性,角度)
    p_w_picpathView.transform = CGAffineTransformRotate(p_w_picpathView.transform, rotation.rotation);
    rotation.rotation = 0;
    
//    NSLog(@"旋转");
}
//2.长按
- (void)longPressAction:(UILongPressGestureRecognizer *)longPress
{
    //长按的方法在手势的各个状态都会触发,所以需要进行判断
//    longPress.state
    if (longPress .state == UIGestureRecognizerStateBegan) {
        NSLog(@"长按开始喽噢!!");
    }else if (longPress.state == UIGestureRecognizerStateEnded){
        NSLog(@"长按结束了呢!!");
    }
}
//1.点击点击手势,的触发方法
- (void)tapAction:(UITapGestureRecognizer *)tap
{
    NSLog(@"快看,那是个塔!");
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}