I'd like to first say I'm a little new to anything but tutorial examples, so sorry if this is a daft question.
I have modified some sample code ever so slightly so that instead of closing a UIImagePickerController once the user has picked an image it processes it in the background.
This seems to work quite well, but once the user has picked all of the images they want to process the only button they're presented with is "Cancel".
I was hoping to change the code so that it adds the selected image to a scrolling view at the bottom of the image picker, but can't find a way to stack or overlay anything onto the UIImagePickerController view.
The code I have so far is below:
-(IBAction)LoadPhotoAlbums:(id)sender
{
NSLog(@"LoadPhotoAlbums");
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
return;
}
if(photoPicker == NULL) {
photoPicker = [[UIImagePickerController alloc] init];
photoPicker.delegate = self;
photoPicker.allowsImageEditing = NO;
}
photoPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:photoPicker animated:YES];
[pool release];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
if([[info objectForKey:@"UIImagePickerControllerMediaType"] isEqualToString:K_UI_TYPE_IMAGE])
{
NSLog(@"Image Selected");
selectedImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"ddMMMyyyyHHmmss"];
NSString *date = [dateFormatter stringFromDate:[NSDate date]];
NSData *imageData = UIImageJPEGRepresentation(selectedImage,0.9);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
selectedImagePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpg", date]];
NSLog(@"Image path is %@", selectedImagePath);
if([imageData writeToFile:selectedImagePath atomically:YES])
NSLog(@"Write Successful");
}
//[picker dismissModalViewControllerAnimated:YES];
//add to listofimages view.
[self uploadSelectedImage];
}