Welcome to the iMore Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Results 1 to 1 of 1
  1. Thread AuthorThread Author   #1  
    Lloydworth's Avatar
    iPhone Nanite

    1 Posts

    Question Displaying photos from NSDocumentDirectory

    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.

        - (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.

        - (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?

Tags for this Thread

Posting Permissions