Why is NSImage not showing in NSImageView?

I have created a document-based project with a storyboard containing an NSScrollView, where I changed the class of the NSClipView's child to NSImageView. As part of the debugging, I have added to the NSImageView a couple of NSButtons with some standard NSImage icons.


The NSImage is being created from a *.png file using a trivial "override func read(from url: URL, ofType typeName: String)" in the Document.swift. I know the image is being created properly, since it will display in the NSButtons when I set their .image var. However, neither my image, nor the button icon images will display in the NSImageView within the scroll view.


I know the scroll view is functioning, since I can pinch & zoom, and the buttons will move and resize as expected.


I thought that an app that read and displayed an image in a scroll view would be trivial to write. Once again, reality is nastier than my imagination.


Thanks,


Richard

OK, I've answered my own question.


The right thing to do is to add an NSImageView to a storyboard and THEN to embed it in a NSScrollView.


The wrong thing to do is to add an NSScrollView to a storyboard and to change the class of the NSClipView's child to NSImageView.

Great you found the solution.


Please mark your own answer as correct.

Why is NSImage not showing in NSImageView?
 
 
Q