如何在轻按手势上选择图像。我想添加另一个与我点击的图像相同的图像。如果我有 3 张图片并且我点击了第 2 张,那么它将动态添加与第 2 张相同的第 4 张图片。
UIImage *image = [[info objectForKey:@"UIImagePickerControllerOriginalImage"] retain];
UIView *holderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, image.size.width/4, image.size.height/4)];
UIImageView *imageview = [[UIImageView alloc] initWithFrame:[holderView frame]];
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
[tapRecognizer setNumberOfTapsRequired:1];
[tapRecognizer setDelegate:self];
[holderView addGestureRecognizer:tapRecognizer];
-(void)tapped:(id)sender {
[[[(UITapGestureRecognizer*)sender view] layer] removeAllAnimations];
NSLog(@"Tapped");
[self.view bringSubviewToFront:[(UITapGestureRecognizer*)sender view]];
UIImageView *image = (UIImageView *)[(UITapGestureRecognizer*)sender view];
[self.view addSubview:image];
}
我[(UITapGestureRecognizer*)sender view]]
用来获得这种观点。但我不能。在点击时,我想添加我点击的图像。