I have a button to capture picture then it save to photoAlbum. I used another button for load image from using imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
then i implemented didFinishPickingMediaWithInfo:
for loading photo album to newImage. My need is after capture photo i have alertview then click YES button automatically load last captured image PhotoAlbum and add newImage. Is it possible?
- (void)saveImageToPhotoAlbum
{
[self.library saveImage:[self stillImage] toAlbum:@"Album" withCompletionBlock:^(NSError *error) {
if (error!=nil) {
NSLog(@"Big error: %@", [error description]);
}
}];
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Gallery"
message:@"Do you want to use the captured image?" delegate:self
cancelButtonTitle:@"Cancel" otherButtonTitles:@"Yes", nil];
alertView.tag = 2;
[alertView show];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
//set image
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
newImage = [[UIImageView alloc] initWithImage:[info objectForKey:UIImagePickerControllerOriginalImage]];
[newImage setFrame:CGRectMake(0, 0, 320, 568)];
[self.view addSubView:newImage];
}
I need to display last captured image to newImage click of alertView button:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 1){
}
}