View Full Version : cocoa objective c pdfview not loaded in nsviewcontroller subview

May 30, 2012, 01:59 AM
I am a newbie for MAC development, I have a simple Cocoa Application using NSViewController where I have a main view and 2 NSViewController and dynamically flipping them. I have added PDFView on NSViewController view to show pdf pages flipping at run time. but my problem when the views are added dynamically then on PDFView I can see the pdf page after resizing the window. I tried using [[pdfViewOutlet1 view] setNeedsDisplay:YES]; for both the views.

FirstView *FirstViewController = [[FirstView alloc] initWithNibName:kFirstView bundle:nil];

[FirstViewController setPdfDoc:pdfDoc];
[FirstViewController setPageCnt:pageCnt];
self.myCurrentViewController = FirstViewController;
[[_myCurrentViewController view] setNeedsDisplay:YES];
[transition setSubtype:kCATransitionFromLeft];

[[_myTargetView animator] addSubview: [_myCurrentViewController view]];

and in the awakeFromNib: method of first view I have:

if(pdfDoc==nil )

[pdfViewOutlet1 setDisplayMode: kPDFDisplaySinglePageContinuous]; //kPDFDisplaySinglePage or kPDFDisplayTwoUp;
[pdfViewOutlet1 setDocument:pdfDoc];

NSRect myRect = { { 0,0 }, { 450, 200 } };
[pdfViewOutlet1 setFrame: myRect];

[pdfViewOutlet1 goToPage: [[pdfViewOutlet1 document] pageAtIndex: pageCnt]];
[pdfDoc release];
[[pdfViewOutlet1 view] setNeedsDisplay:YES];

How can I see the pdf pages without resizing the views using mouse?

Please Help!