我有 4 个 UIButtons 和 4 个 UIImgeViews,每个按钮都应该使用 UIImagePickerController 更改其 UIImageView 的图像。按钮 #1 应该改变 imageview #1 等等。一切都应该不同。仅使用第一个按钮和 imageview 即可正常工作,但我不确定如何将其应用于所有 4 个按钮。
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image1 = [info objectForKey:UIImagePickerControllerOriginalImage];
NSData *data = UIImagePNGRepresentation(image1);
NSString *myGrabbedImage = @"myGrabbedImage.png";
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [path objectAtIndex:0];
NSString *fullPathToFile = [documentDirectory stringByAppendingPathComponent:myGrabbedImage];
[data writeToFile:fullPathToFile atomically:YES];
[[self firstImageView]setImage:image1];
[self dismissViewControllerAnimated:YES completion:nil];
}
我知道这只会将图片设置为第一个 imageView 但我怎样才能为所有 4 做呢?