I have used the Imagepickerview controller to pick the photo and display it in uiview using imageview but my problem is using imageview only one image can able to display not two. its keep on replacing the existing one if i select second one. please give some suggestions how to display two photos.
here is my source code.
-(void) ViewDidLoad
{
attachPhotoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
attachPhotoBtn.frame = CGRectMake(400, 125, 44, 44);
UIImage *attachImg = [UIImage imageNamed:@"album_add_off.png"];
[attachPhotoBtn setImage:attachImg forState:UIControlStateNormal];
[attachPhotoBtn addTarget:self action:@selector(attachPhoto:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:attachPhotoBtn];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 125, 64, 52)];
// imageView.backgroundColor = [UIColor greenColor];
[self.view addSubview:imageView];
}
}
- (IBAction)attachPhoto:(id)sender {
[sender setImage:[UIImage imageNamed:@"album_add.png"] forState:UIControlStateNormal];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage,(NSString *)kUTTypeVideo,nil];
imagePicker.allowsEditing = NO;
// On iPad use pop-overs.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
_popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[_popover presentPopoverFromRect:attachPhotoBtn.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
}
}
else
{
// On iPhone use full screen presentation.
// [[self presentingViewController] presentViewController:imagePicker animated:YES completion:nil];
}
newMedia = NO;
}
#pragma mark Image picker controller delegate methods
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
// [self dismissModalViewControllerAnimated:YES];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
imageView.image = image;
[picker dismissViewControllerAnimated:NO completion:nil];
}