Iphone 如何在多个UIView或UIImageView上使用UIGestureRecognitors进行点击、挤压和旋转
我不知道;我不知道如何处理这个问题:-/ 我只需要在图像上添加标签。应用程序将在选择特定的贴纸时添加笑脸、红心(图像)等贴纸,并将其添加到主图像中,用户可以使用贴纸进行操作,如旋转、缩放等,用户可以选择多个贴纸,并可以使用添加的贴纸进行旋转缩放等Iphone 如何在多个UIView或UIImageView上使用UIGestureRecognitors进行点击、挤压和旋转,iphone,ios,objective-c,image-processing,uigesturerecognizer,Iphone,Ios,Objective C,Image Processing,Uigesturerecognizer,我不知道;我不知道如何处理这个问题:-/ 我只需要在图像上添加标签。应用程序将在选择特定的贴纸时添加笑脸、红心(图像)等贴纸,并将其添加到主图像中,用户可以使用贴纸进行操作,如旋转、缩放等,用户可以选择多个贴纸,并可以使用添加的贴纸进行旋转缩放等 请指导如何实现这一点,我能够使用单个贴纸执行图像复制我不知道如何使用多个贴纸选择,用户可以再次返回到任何贴纸并对其执行操作。我希望您在单击“粒子图像”时向图像视图添加手势您希望对该粒子图像执行一些操作,然后像这样尝试可能会对您有所帮助 UITapGes
请指导如何实现这一点,我能够使用单个贴纸执行图像复制我不知道如何使用多个贴纸选择,用户可以再次返回到任何贴纸并对其执行操作。我希望您在单击“粒子图像”时向图像视图添加手势您希望对该粒子图像执行一些操作,然后像这样尝试可能会对您有所帮助
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapped:)];
添加此选项可同时识别手势
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
return YES:
}
我期待你在图像视图中添加手势,当你点击特殊图像时,你想在特殊图像上执行一些动作,对吧,然后像这样尝试可能会对你有帮助
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapped:)];
添加此选项可同时识别手势
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
return YES:
}
您可以使用以下方法添加手势:
- (void) addGestureRecognizers{
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
[self addGestureRecognizer:panRecognizer];
UIRotationGestureRecognizer *rotateRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];
self.multipleTouchEnabled = YES;
[self addGestureRecognizer:rotateRecognizer];
UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)];
[self addGestureRecognizer:pinchRecognizer];
UILongPressGestureRecognizer *longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressed:)];
longPressRecognizer.minimumPressDuration = 2.0;
[self addGestureRecognizer:longPressRecognizer];
}
并实现这些选择器:
- (void) move:(UIPanGestureRecognizer *)recognizer{
CGPoint translation = [recognizer translationInView:self.superview];
recognizer.view.center = CGPointMake(recognizer.view.center.x+translation.x, recognizer.view.center.y+translation.y);
[recognizer setTranslation:CGPointMake(0, 0) inView:self.superview];
}
- (void) rotate:(UIRotationGestureRecognizer *)recognizer{
NSLog(@"Rotate");
recognizer.view.transform = CGAffineTransformRotate(
recognizer.view.transform,
recognizer.rotation);
recognizer.rotation = 0;
}
- (void) pinch:(UIPinchGestureRecognizer *)recognizer{
recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale, recognizer.scale);
recognizer.scale = 1;
}
- (void) longPressed:(UILongPressGestureRecognizer *)recognizer{
NSLog(@"Long Pressed");
}
注意:根据需要更改值您可以使用以下方法添加手势:
- (void) addGestureRecognizers{
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
[self addGestureRecognizer:panRecognizer];
UIRotationGestureRecognizer *rotateRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];
self.multipleTouchEnabled = YES;
[self addGestureRecognizer:rotateRecognizer];
UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)];
[self addGestureRecognizer:pinchRecognizer];
UILongPressGestureRecognizer *longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressed:)];
longPressRecognizer.minimumPressDuration = 2.0;
[self addGestureRecognizer:longPressRecognizer];
}
并实现这些选择器:
- (void) move:(UIPanGestureRecognizer *)recognizer{
CGPoint translation = [recognizer translationInView:self.superview];
recognizer.view.center = CGPointMake(recognizer.view.center.x+translation.x, recognizer.view.center.y+translation.y);
[recognizer setTranslation:CGPointMake(0, 0) inView:self.superview];
}
- (void) rotate:(UIRotationGestureRecognizer *)recognizer{
NSLog(@"Rotate");
recognizer.view.transform = CGAffineTransformRotate(
recognizer.view.transform,
recognizer.rotation);
recognizer.rotation = 0;
}
- (void) pinch:(UIPinchGestureRecognizer *)recognizer{
recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale, recognizer.scale);
recognizer.scale = 1;
}
- (void) longPressed:(UILongPressGestureRecognizer *)recognizer{
NSLog(@"Long Pressed");
}
注意:根据需要更改值您的意思是说您旋转一个贴纸,所有贴纸都会旋转吗?没有用户会通过点击来选择一个贴纸,只有该贴纸会旋转、缩放或移动您的意思是说您旋转一个贴纸,所有贴纸都会旋转吗?没有用户会通过点击来选择一个贴纸,只有该贴纸会旋转、缩放或移动是的,但我不知道如何进一步操作,例如如何在选定的视图上执行旋转、缩放等我需要指导选择任何贴纸时我需要为每个贴纸创建一个新的UIImageView,然后如何将手势识别器添加到此新视图创建图像视图后,您可以在该图像视图上添加手势是的,但我不知道如何进一步操作,例如如何在所选视图上执行旋转、缩放等我需要在选择任何贴纸时获得指导我需要为每个贴纸创建一个新的UIImageView,那么,如何将手势识别器添加到此新视图创建图像视图后,您可以在该图像视图上添加手势当选择任何标签时,是否每次都需要创建新的UIImageView?然后在视图中添加手势我不能说任何话,除非看到你的代码伙伴。你说的var是什么意思?不管怎样,谢谢你,这将有助于我像其他照片应用程序一样在图像上添加贴纸。。我现在有多个贴纸,你建议为每个贴纸添加一个图像视图吗。是的,您必须为要使用的每个标签添加UIImageView。否则就没有办法显示标签了吗?顺便说一句,如果我的回答对你有帮助的话,你可以投票或者接受我的回答:是的,我知道了,还有一件事,我会有多个图像视图。。如何获取选择的图像以及必须在哪个图像视图上执行旋转、缩放等操作当选择任何标签时,是否每次都需要创建新的UIImageView?然后在视图中添加手势我不能说任何话,除非看到你的代码伙伴。你说的var是什么意思?不管怎样,谢谢你,这将有助于我像其他照片应用程序一样在图像上添加贴纸。。我现在有多个贴纸,你建议为每个贴纸添加一个图像视图吗。是的,您必须为要使用的每个标签添加UIImageView。否则就没有办法显示标签了吗?顺便说一句,如果我的回答对你有帮助的话,你可以投票或者接受我的回答:是的,我知道了,还有一件事,我会有多个图像视图。。我如何才能获得选择的图像以及我必须在哪个图像视图上执行旋转、缩放等操作