是否有一个类来获取应用程序中的默认图片查看器?

问题描述:

我不想访问iphone上的图像,我想从我的应用程序中显示图像,但就像你在iphone的图片专辑中查看图片一样 - 包括所有的捏合和缩放控制等。

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.

这可能吗?我认为可能(偶然)会像AVMediaPlayer这样的类来做这个吗?

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

谢谢
Tom

Thanks Tom

如果你的目标是4.0或更高版本,你可以使用 QLPreviewController

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

包括 #import<你班上的QuickLook / QuickLook.h>

以下是如何创建一个:

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;
}