Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios PinchGesture激活时不调用旋转手势_Ios - Fatal编程技术网

Ios PinchGesture激活时不调用旋转手势

Ios PinchGesture激活时不调用旋转手势,ios,Ios,我有drawingView和listen UIPangEstureRecognitor、UIRotationGestureRecognitor和UIPinchGestureRecognitor - (void)viewDidLoad { [super viewDidLoad]; UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@s

我有drawingView和listen UIPangEstureRecognitor、UIRotationGestureRecognitor和UIPinchGestureRecognitor

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panDetected:)];
    [self.drawingView addGestureRecognizer:panRecognizer];

    UIRotationGestureRecognizer *rotateRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotateRecognizer:)];
    [self.drawingView addGestureRecognizer:rotateRecognizer];

    UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchRecognizer:)];
    [self.drawingView addGestureRecognizer:pinchRecognizer];
    [self.drawingView reloadData];
}

-(void) pinchRecognizer:(UIPinchGestureRecognizer*) recognizer {
    return;
    NSLog(@"Call scale");
}

- (void)rotateRecognizer:(UIRotationGestureRecognizer*)recognizer {
    NSLog(@"Call rotaion");
}
如果我只选择UIRotationGestureRecognizer或UIPinchGestureRecognizer,它是完美的。但是,如果仅使用UIRotationGestureRecognizer和UIPinchGestureRecognizer调用UIPinchGestureRecognizer,则不会调用UIRotationGestureRecognizer。 我的代码有什么问题? 我想我会做一个UISegmented来选择模式,UIRotationGestureRecognitor或UIPinchGestureRecognitor,我该怎么做


非常感谢

如果您想同时识别多个手势,请尝试使用
手势识别器:应使用手势识别器同时识别,例如:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}
编辑:除了在.h中包含代理外,请确保将
UIgestureRecognitor
的代理设置为self,例如:

UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panDetected:)];
panRecognizer.delegate = self;
[self.drawingView addGestureRecognizer:panRecognizer];

UIRotationGestureRecognizer *rotateRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotateRecognizer:)];
rotateRecognizer.delegate = self;
[self.drawingView addGestureRecognizer:rotateRecognizer];

如果其他手势识别器未执行,请使用
requiregestrerecognizertofail:
识别该手势

[rotateRecognizer requireGestureRecognizerToFail: pinchRecognizer];

我在ViewControler.m中添加了函数,在ViewControler.h中添加了函数,但问题没有解决。您需要将手势的代理设置为“self”。在上面的编辑中添加。仅供参考,夹点识别器方法中的NSLog位于“return”之后,因此不会打印出来。