Resizing problem in PDFView sample SOLVED
Resizing problem in PDFView sample SOLVED
- Subject: Resizing problem in PDFView sample SOLVED
- From: Joel Norvell <email@hidden>
- Date: Thu, 15 Nov 2007 21:29:26 -0800 (PST)
Dear Cocoa-dev People,
About a year ago, I posted a note on Cocoa-dev asking how to make PDFView (the
sample application) resize "normally."
By "normally," I meant that resizing the window should either reveal more of
the document as the window grew, or clip the bottom of the document as the
window is shrunk.
Previously, if you were to drag the bottom-right corner of the window upward,
shrinking its height, the bottom of the original document remained visible,
while the document scrolled upward.
I probably shouldn't have originally posted this on a Friday night, because
there were no replies. So the question remained unsettled UNTIL a recent
Silicon Valley NSCoder Night.
Thanks NSCoder Friends!
Joel
The PDFView sample code is here:
http://developer.apple.com/samplecode/PDFView/
(N.B. This is not related to PDFKit.)
Add this to PDFImageView.h:
NSSize clipViewSize;
And add these methods to PDFImageView.m:
- (void) awakeFromNib
{
NSClipView *clipView = [[self enclosingScrollView] contentView];
NSParameterAssert(nil != clipView);
clipViewSize = [clipView frame].size;
[clipView setPostsFrameChangedNotifications: YES];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
nc addObserver: self
selector: @selector(clipViewFrameDidChange:)
name: NSViewFrameDidChangeNotification
object: clipView];
}
- (void) clipViewFrameDidChange:(NSNotification *) notification
{
NSSize newClipViewSize = [[notification object] frame].size;
NSPoint scrollPosition = [[notification object] bounds].origin;
scrollPosition.y = (scrollPosition.y +
(clipViewSize.height - newClipViewSize.height));
[self scrollPoint: scrollPosition];
clipViewSize = newClipViewSize;
}
____________________________________________________________________________________
Get easy, one-click access to your favorites.
Make Yahoo! your homepage.
http://www.yahoo.com/r/hs
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden