How to get a PDFView to display a PDF without changing the window size or execution scroll to force redrawing.
As if you need to execute setNeedsDisplay
, but this has no effect.
I have the simplest application that I can come up with to show PDF using PDFView.
Basically create a new application in Xcode and change the code:
// AppDelegate.h #import <Cocoa/Cocoa.h>
and
// AppDelegate.m
I noticed the same behavior in the Apple PDFKitLinker2 code example, where you need to either scroll the PDF file or resize the window to get a PDF file display.
Of course, I am new to the Cocoa development world, but I searched and did not find really small examples showing how to display PDF. What I released seems to be correct, but I doubt even PDFKitLinker2 seems to be correct.
I created the Git repository of the Xcode project , which demonstrates the problem for those who have time to help and / or comment.
git clone git@bitbucket.org :sotapme/pdfview_open.git
Using Xcode version 4.3.3 (4E3002) is the last lion.
Thanks in advance for your help.
Solution that works.
I found a solution in which if I create a subclass of the PDFView class with an empty implementation and then add this as a custom view and plug in its existing IBOutlet
, it works.
It makes no sense to me :(
//DPPDFView.h #import <Quartz/Quartz.h> @interface DPPDFView : PDFView @end
and
//DPPDFView.m
Apple docs say:
PDFView may be the only class you need to deal with adding PDF features to your application. It allows you to display data in PDF format and allows users to select content, navigate through the document, set the zoom level and copy text content to the Pasteboard. PDFView also tracks page history.
You can subclass PDFView to create a custom PDF viewer.
I leave this question and the answer itself to those who can pass by similar questions, hoping that this will be a dim beacon of light for them; Also hoping that someone with more Cocoa wisdom will point out an error in my thoughts.