QLPreviewController委托方法在iOS 10中不会被调用,但是如果运行于iOS 10之前,则会被调用 [英] QLPreviewController delegate method doesn't get called in iOS 10, but does get called if ran earlier than iOS 10

查看:285
本文介绍了QLPreviewController委托方法在iOS 10中不会被调用,但是如果运行于iOS 10之前,则会被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码.这听起来像是多余的问题,但是我的情况有所不同,因为我没有将QLPreviewController添加为子视图,而是作为控制器存在.

Here is my code. This may sound like redundant question but my scenario is different as I am not adding QLPreviewController as a subview but present as a controller.

从保管箱下载后,我将其显示为-

After downloading from dropbox, I present it like-

    self.pdfViewController = [[QLPreviewController alloc] init];
    self.pdfViewController.delegate = self;
    self.pdfViewController.dataSource = self;

    [self presentViewController:self.pdfViewController animated:YES completion:nil];

,我也将QLPreviewControllerDataSource, QLPreviewControllerDelegate列为协议.此外,它可以在iOS 10.0之前的版本中运行.

and I also have QLPreviewControllerDataSource, QLPreviewControllerDelegate listed as the protocol. Besides, it is working if being run in earlier than iOS 10.0.

请帮助我.

推荐答案

iOS 10似乎已经改变了QLPreviewController的显示方式.在iOS 9上,通过模态显示QLPreviewController预览图像时,我看到了不错的缩放效果,并且预览的初始状态是黑色背景,并且导航和工具栏处于隐藏状态.我可以点击图像以使条形可见(将背景更改为白色).再次轻按即可切换状态.

It looks like iOS 10 has changed the way that QLPreviewController is presented. On iOS 9 when I preview an image by presenting the QLPreviewController modally I see a nice zoom effect and the initial state of the preview is with a black background and the navigation and toolbar hidden. I can tap the image to make the bars visible (which changes the background to white). Tapping again toggles the state.

在iOS 10上,相同的代码导致出现白色背景视图,并且缩放动画不正确(似乎从屏幕底部出现).

On iOS 10 the same code results in the white background view appearing and the zoom animation being incorrect (it seems to appear from off the bottom of the screen).

我发现,针对iOS 10实施这种实际上未记录的新数据源方法可以解决此问题:

I found that implementing this practically undocumented new data source method for iOS 10 fixed the issue:

- (UIView* _Nullable)previewController:(QLPreviewController *)controller
          transitionViewForPreviewItem:(id <QLPreviewItem>)item
{
    return [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:MIDPhotoImageRowIndex_Image inSection:MIDPhotoSectionIndex_Image]];
}

我返回的视图与previewController:frameForPreviewItem:inSourceView:用作原始内容框架的参考的视图相同(即,我的表格单元格中的图像视图).

The view I return is the same view that previewController:frameForPreviewItem:inSourceView: is using as the reference for the original content's frame (i.e. the image view in my table cell).

此委托方法的文档在撰写本文时,只说没有概述".

The documentation for this delegate method at the time of writing just says "No overview available".

实施该方法的确意味着previewController:frameForPreviewItem:inSourceView:现在在iOS 10上被调用.我只是希望有一种方法可以默认不使用导航栏的原始黑色背景.

Implementing that method did mean that the previewController:frameForPreviewItem:inSourceView: is now called on iOS 10. I just wish there was a way to default to the original black background without navigation bars.

这篇关于QLPreviewController委托方法在iOS 10中不会被调用,但是如果运行于iOS 10之前,则会被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆