![]() Creating my own page controller and render a single PDF page per page (not using ePageViewController)ĭoes anyone have any ideas of how I can achieve what I'm after?.Intercepting the pinch gesture and adjusting the document view's center.Adjusting the transform on the document view.PDFViewVisiblePagesChanged which does fire as the next/previous pages are coming into view (as well as a few more times, which is fine) and this has the same issue as with. PDFViewPageChanged notification only fires after the scroll view ends decelerating, so the page is zoomed out as it's scrolling in and then when I adjust the scale factor it jumps to fit the width of the screen. To attempt to solve the "tall page problem" () I've tried adjusting the scale factor of the PDFView whenever a new page appears. This approach, aside from relying on private view hierarchy, just won't work. However, once the user pinches to zoom on that page, its frame is automatically jumps back to being centered. This works in that whenever the next or previous page is scrolling into view, the page is rendered at the top of the view. First, and this is gross and I know it's wrong, after inspecting the view hierarchy and finding the private view (a view of class named PDFTextInputView) that the page is rendered within I've tried adjusting its frame's origin.y to 0 whenever the outer-most scrollview (another private view) scrolls. To attempt to solve the first issue, the vertical offset, I have attempted several things. Each page is centered vertically in the PDFView, and if its height of the page is greater than the height of the view (e.g. This is due to the varying heights of the pages. ePageViewController(true, withViewOptions: nil) I would like to use PDFKit's PDFView, especially since these settings can be achieved by: let pdfView = PDFView() Finally, the PDFView’s document is set, which in turn is added to the existing view for display on the screen.I have a PDF that has pages of different heights that I want to display in a horizontally paged fashion, one page at a time, with no gaps between pages, and the top of each page being aligned with the top of the view. In the code example, we are creating the PDFView at a specific size, then setting up a PDFDocument with a PDF from the main bundle. PDFDocument manages the details of the document itself, as well as handling searching, writing, and selecting data within the PDF file. The PDFView object is the primary one you’ll be working with and controls the display area, nagivation, which PDF is loaded, and which page of the PDF is shown. Here’s a quick explanation of the code above: NSString *pathToPDF = *pdfDoc = initWithURL:] īe sure to read the official PDFKit documentation to better understand how all of these objects work. Then add this code to viewDidLoad or whatever other function you want to do this work: PDFView *pdfView = initWithFrame: Import PDFKit into your project at the top of your file: #import It displays a PDF file in the default vertical scroll view at the size of the current view. To start, here is the simplest implementation you can get, with no customization or options. Along with that, I’ll be including all of my code in a GitHub repository for reference and testing. With that in mind, I’m planning a series of blog posts to cover the use of PDFKit, to help other developers who are implementing it using Objective-C. In fact, even some of Apple’s documentation only includes Swift examples. ![]() ![]() While working with PDFKit on a project this year, I found the general online support to be somewhat lacking, especially for Objective-C. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |