1. Lloydworth's Avatar
    I'm developing this application on an iPad.

    These codes for a 'Browse' button allows the user to view the photos from the iPad's gallery.

    Code:
        - (IBAction) BrowsePhoto:(id)sender
        {
        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
        imagePickerController.delegate = self;
        imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
        [popover setPopoverContentSize:CGSizeMake(320,320)];
        [popover presentPopoverFromRect:CGRectMake(200,200,-100,-100) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        self.popoverController = popover;
        [imagePickerController  release];
        }
    When a photo is selected, it will be stored into the application using NSDocumentDirectory.

    Code:
        - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editingInfo 
        {
        [self.popoverController dismissPopoverAnimated:YES];
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDir = [paths objectAtIndex:0];
        NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:@"SavedImage.png"];
        UIImage *image = imageView.image;
        NSData *imageData = UIImagePNGRepresentation(image);
        [imageData writeToFile:savedImagePath atomically:NO];
        }
    Now i have to include a 'Display' button on the first screen.
    When tapped on the button, it will show a new view (modal view controller) and displays all the photos in thumbnails/tableview from the NSDocumentDirectory.

    When a photo is selected, it will be deleted from the NSDocumentDirectory.

    How can i do this?
    10-04-2011 02:43 AM
LINK TO POST COPIED TO CLIPBOARD