使用两个 UIImageview 和两个按钮时点击第一个按钮图像选择器让您选择图像
从照片库和第二个按钮相同。这就是我所做的
视图控制器.h
UIImagePickerController *pic1;
UIImagePickerController *pic2;
UIImage *image1;
UIImage *image2;
IBOutlet UIImageView *imageview1;
IBOutlet UIImageView *imageview2;
-(IBAction)Load1:(id)sender;
-(IBAction)Load2:(id)sender;
vewcontroller.m
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
image1 = [info objectForKey:UIImagePickerControllerOriginalImage];
image2 = [info objectForKey:UIImagePickerControllerOriginalImage];
[imageview1 setImage:image1];
[imageview2 setImage:image2];
[self dismissViewControllerAnimated:YES completion:NULL];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (IBAction)Load1:(id)sender
{
pic1 = [[UIImagePickerController alloc]init];
pic1.delegate = self;
[pic1 setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:pic1 animated:YES completion:NULL];
}
- (IBAction)Load2:(id)sender
{
pic2 = [[UIImagePickerController alloc]init];
pic2.delegate = self;
[pic2 setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:pic2 animated:YES completion:NULL];
}
当我跑的时候。第一个按钮工作。让您从照片库中选择图像并显示它,第二个按钮照常工作,但您选择的图像同时显示在 UIImageview
我在这里做错了什么,谢谢