views:

25

answers:

1

Hi there

I don't want to access the images on the iphone, I want to display an image from my app, but like you view pictures in the picture album of the iphone - with all the pinch and zoom controls and such.

Is this possible? I thought there might (by chance) be some class like the AVMediaPlayer class that would do this?

Thanks Tom

+1  A: 

If you're targeting 4.0 or later you can use QLPreviewController:

Include #import <QuickLook/QuickLook.h> in your class

Here is how to create one:

Class qlookclass = NSClassFromString(@"QLPreviewController");
        if(qlookclass){
            //check if the image exists
            if([[NSFileManager defaultManager] fileExistsAtPath:@"someimage.png"]){
                id quickLookPreview = [[qlookclass alloc]init];
                [quickLookPreview setDataSource:self];
                [self presentModalViewController:quickLookPreview animated:YES];
                [quickLookPreview release];
            }
        }

Then somewhere else in your view controller:

#pragma mark QLPreviewController delegate methods

- (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller {
    return 1;
}

- (id <QLPreviewItem>) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index {

    NSURL *imageURL =  [NSURL fileURLWithPath:@"someimage.png"];

    return imageURL;
}
christo16
:) that's amazing, thank you - will try it ASAP. :)
Thomas Clayson
took a bit of tweaking, but works a dream, thank you. :)
Thomas Clayson