捏手势 - PinchOut Xcode iPhone

时间:2013-03-03 01:55:57

标签: iphone xcode ipad uiview gesture

我想限制我的View仅在UIPinchGesture“检测到捏合”时进行缩放。 这是我的代码,它不起作用,因为它不会将UIPinchGesture限制为只有Pinch out&不进行捏合,可以通过捏合和捏合来检测。 提前致谢!丹尼尔

-(void)PinchOutGesture {

UIPinchGestureRecognizer *longPress_gr1 = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(doAction1:)];

//pinch out//
if(longPress_gr1.scale > 1) {


     [View addGestureRecognizer:longPress_gr1];
    //something happens
}


//Pinch in
if(longPress_gr1.scale < 1) {

    View = nil;
    //nothing happens

  }

}



- (void)doAction1:(UIPinchGestureRecognizer *)recognizer {


    View.userInteractionEnabled = NO;

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.25];
    [UIView setAnimationDelay:0.0];

    View.frame = CGRectMake(30, 64, 260, 334);
    View.alpha = 0.5;


    [UIView commitAnimations];

}

0 个答案:

没有答案
相关问题