The QLPreviewController delegate method is not called in iOS 10, but calls if it was launched earlier than iOS 10

Here is my code. This may sound like a redundant question, but my script is different from the fact that I am not adding QLPreviewController as a subordinate, but present as a controller.

After loading from dropbox I present it as -

self.pdfViewController = [[QLPreviewController alloc] init]; self.pdfViewController.delegate = self; self.pdfViewController.dataSource = self; [self presentViewController:self.pdfViewController animated:YES completion:nil]; 

and I also have QLPreviewControllerDataSource, QLPreviewControllerDelegate , specified as a protocol. In addition, it works if it runs earlier than iOS 10.0.

Please help me.

0
objective-c ios10 pdf-reader qlpreviewcontroller
source share
1 answer

It seems that iOS 10 has changed the way QLPreviewController is QLPreviewController . On iOS 9, when I view the image, introducing the QLPreviewController mod, I see a good zoom effect, and the initial preview state is with a black background and hidden navigation and a toolbar. I can click on the image to make the stripes visible (which changes the background to white). Pressing again switches the state.

In iOS 10, the same code results in a white background image, and the zoom animation is incorrect (it seems to be displayed at the bottom of the screen).

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

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

The returned view is the same view that previewController:frameForPreviewItem:inSourceView: uses as a reference for the original content frame (that is, the image in my table cell).

The documentation for this delegate method at the time of writing is simply saying, "Browse is not available."

The implementation of this method meant that previewController:frameForPreviewItem:inSourceView: now called on iOS 10. I just want the default way to use the original black background without navigation bars.

0
source share

All Articles