Quicklook/QLPreviewController delegate methods are not calling in iOS 10 Xcode 8
Asked Answered
D

1

8

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)

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

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

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

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

[self addChildViewController:previewer];

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];
Dogcatcher answered 31/8, 2016 at 1:19 Comment(1)
Thanks, works with Xamarin.iOS too.Walloon
I
1

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]; 
Injury answered 14/9, 2016 at 6:49 Comment(1)
@ridvankucuk Still do you have issue?Dogcatcher

© 2022 - 2024 — McMap. All rights reserved.