イメージビューへのカスタム認識エンジンのジェスチャを削除したい。カービィターナーから指一本回転です。
-(void) enableRotation{
[[self mainImageView] setUserInteractionEnabled:YES];
[self addRotationGestureToView:[self mainImageView]];
//[self addTapGestureToView:[self mainImageView] numberOfTaps:1];
}
- (void)addTapGestureToView:(UIView *)view numberOfTaps:(NSInteger)numberOfTaps
{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
[tap setNumberOfTapsRequired:numberOfTaps];
[view addGestureRecognizer:tap];
}
- (void)addRotationGestureToView:(UIView *)view
{
NSLog(@"'Adding KT Rotation recognizer to the rotation");
KTOneFingerRotationGestureRecognizer *rotation = [[KTOneFingerRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotating:)];
[view addGestureRecognizer:rotation];
}
- (void)rotating:(KTOneFingerRotationGestureRecognizer *)recognizer
{
UIView *view = [recognizer view];
[view setTransform:CGAffineTransformRotate([view transform], [recognizer rotation])];
}
- (void)removeRotationGestureFromView: (UIImageView *) imgView {
//UIRotationGestureRecognizer *rotate = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationRemoved:)];
//[imgView removeGestureRecognizer:rotate];
KTOneFingerRotationGestureRecognizer *rotation = [[KTOneFingerRotationGestureRecognizer alloc] init];
while(self.mainImageView.gestureRecognizers.count){
[self.mainImageView removeGestureRecognizer:[self.mainImageView.gestureRecognizers objectAtIndex:0]];
//[self.mainImageView removeGestureRecognizer:rotation];
}
NSLog(@"Trying to remove rotation on this gesture");
}
カスタムタイルタブで呼び出しています
if(rotationToggle%2==0){
[self enableRotation];
NSLog(@"%d", rotationToggle);
}
else{
[self removeRotationGestureFromView:self.mainImageView];
NSLog(@"%d", rotationToggle);
}
rotationToggle +=1;
ここで、rotationToggle は静的な int です。
ジェスチャ認識エンジンを 1 つだけ削除するにはどうすればよいですか。現在のメソッドは、イメージ ビュー内のすべてのレコグナイザーを削除します。[imgView removeGestureRecognizer:rotate]; または [self.mainImgView removeGestureRecognizer:rotate];
それは動作しません。前もって感謝します。ここで言い忘れたことがある場合はお知らせください。