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

发布于 2024-09-24 07:58:03 字数 145 浏览 2 评论 0原文

我不想访问 iPhone 上的图像,我想显示我的应用程序中的图像,但就像您查看 iPhone 相册中的图片一样 - 使用所有捏合和缩放控件等。

这可能吗?我认为可能(偶然)有像 AVMediaPlayer 类这样的类可以做到这一点?

谢谢 汤姆

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无法回应 2024-10-01 07:58:03

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

在您的类中包含 #import

以下是创建一个的方法:

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

然后在视图控制器的其他位置:

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

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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文