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];
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];
This answer https://stackoverflow.com/a/41908926/870671 might also resolve the problem you are seeing. I'm presenting my QLPreviewController
, not using view controller containment.
来源:https://stackoverflow.com/questions/39239330/quicklook-qlpreviewcontroller-delegate-methods-are-not-calling-in-ios-10-xcode-8