QLPreviewController委托方法未在iOS

QLPreviewController委托方法未在iOS

本文介绍了Quicklook/QLPreviewController委托方法未在iOS 10 Xcode 8中调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在iOS10中测试我的当前版本.我正在使用 Xcode 8 beta 6进行测试.在这里 Quicklook/QLPreviewController委托方法未调用.该代码集已与XCode 7和iOS 9.3版本一起使用.我在Apple Developer论坛中检查了此问题.但是找不到答案.有人解决了这个问题吗? (我正在使用Objective-C)

Currently I am testing my current version in iOS10. I am using Xcode 8 beta 6 for testing. Here Quicklook/QLPreviewController delegate methods are not calling. This code set had been worked with XCode 7 and iOS 9.3 versions. I checked this issue in Apple Developer forum. But could not find a answer. Anyone have fixed this issue? (I am using Objective-C)

如何在XCode 8( iOS 10 )中使用Quicklook/QLPreviewController?

How to use Quicklook/QLPreviewController in XCode 8 (iOS 10)?

//----------------- iOS 10的解决方案(预览器作为子视图)------------------ -

//----------------- SOLUTION for iOS 10 ( previewer as a subview) -------------------

将预览器添加为子视图时,会发生此问题.然后,我们主要在iOS 9.3及以下版本中使用以下代码行.

This issue is occurred when you add the the previewer as a subview. Then we are using below code lines mainly in iOS 9.3 and below versions.

[self addChildViewController:previewer];
self.view addSubview:previewer.view];
[previewer didMoveToParentViewController:self];

在iOS 10中,由于以下代码行而引起的问题.

In iOS 10 issue comes due to the below code line.

[self addChildViewController:previewer];

对于iOS 10,我们需要检查版本并添加上面的代码行.下面是工作代码集.

For iOS 10 we need to check the version and add above code line. Below is the working code set.

    QLPreviewController* previewer = [[QLPreviewController alloc] init];

    previewer.dataSource = self;
    previewer.delegate = self;
    // To avoid iOS 10 previewer issue.
    if (SYSTEM_VERSION_LESS_THAN(@"10.0")) {
        [self addChildViewController:previewer];
    }
    CGFloat width = self.view.frame.size.width;
    CGFloat height = self.view.frame.size.height;
    previewer.view.frame = CGRectMake(0, 102, width, height-300);
    [self.view addSubview:previewer.view];

    [previewer didMoveToParentViewController:self];

推荐答案

我也遇到了这个问题,但是您的解决方案无法解决此问题.这是我的代码:

I met this problem too, but I can't fix this issue by your solution..Here is my code:

QLPreviewController *preview = [[QLPreviewController alloc] init];
[preview setDataSource:self];
[preview setDelegate:self];

if(SYSTEM_VERSION_LESS_THAN(@"10.0"))
{
    [self addChildViewController:preview];
}

[preview didMoveToParentViewController:self];
[self.view addSubview:preview.view];

这篇关于Quicklook/QLPreviewController委托方法未在iOS 10 Xcode 8中调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 06:28