Centering image view in scroll view


Steve Mills
 

Ack. I'm having a hard time figuring out how to make an NSImageView in an NSScrollView act like it does in Preview.app, where it will stay centered within the window when any axis is smaller than the window, but still be zoomable by the user. What magic combination of settings, methods, and/or constraints do I need?

I have an NSViewController, if I need to override some methods there. Its view contains the scroll view. I initially want the image to fit within the window, so I calculate and set the scroll view's magnification in viewWillAppear.

Steve via iPhone

Join {cocoa@apple-dev.groups.io to automatically receive all group messages.