There are lots of examples out there of how to get NSScrollView to center its document view. Here are two examples (which are so similar that somebody is copying somebody
1) make sure the view (documentView) directly under the clip view has no constraints to the clip view! (if so, check, remove at build time)
2) subclass NSClipView
@implementation CenterClipView
- (NSRect)constrainBoundsRect:(NSRect)proposedClipViewBoundsRect {
NSRect rect = [super constrainBoundsRect:proposedClipViewBoundsRect];
NSView * view = self.documentView;
if (view) {
if (rect.size.width > view.frame.size.width) {
rect.origin.x = (rect.size.width - view.frame.size.width) / 2.;
}
if(rect.size.height > view.frame.size.height) {
rect.origin.y = (rect.size.height - view.frame.size.height) / 2.;
}
}
return rect;
}
@end
3) change the NSClipView to your subclass