Zooming in and out in WebView
Zooming in and out in WebView
- Subject: Zooming in and out in WebView
- From: qvacua <email@hidden>
- Date: Thu, 17 May 2012 14:40:00 +0200
Hi!
I am having trouble to zoom in and out in WebView. I have a subclass
of WebView with the following zoom code:
- (void)zoomByFactor:(CGFloat)factor {
WebFrameView *frameView = self.mainFrame.frameView;
NSView <WebDocumentView> *const docView = frameView.documentView;
NSScrollView *scrollView = docView.enclosingScrollView;
NSClipView *clipView = scrollView.contentView;
NSView *viewToScale = docView;
NSSize oldScale = [viewToScale convertSize:UNIT_SIZE toView:nil];
NSSize newScale = NSMakeSize(oldScale.width * factor,
oldScale.height * factor);
[viewToScale scaleUnitSquareToSize:[viewToScale
convertSize:UNIT_SIZE fromView:nil]];
[docView scaleUnitSquareToSize:newScale];
[docView setFrameSize:[docView convertSize:[docView bounds].size
toView:nil]];
[docView setNeedsLayout:YES];
[self setNeedsDisplay:YES];
}
where UNIT_SIZE = NSMakeSize(1, 1).
Zooming out seems to work, however, zooming in does not work. The web
page gets zoomed in, however, the page gets clipped on the right side.
There is a white strip. Zooming in further makes that white strip
wider. Am I missing some convenient method? If not, how can I properly
zoom a WebView?
Thanks in advance,
Tae
_______________________________________________
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