Unable to set image in NSImageView subclass

124 views Asked by At

I have a very basic NSImageView Sub Class, and adding it via a Custom View item in the Interface Builder from XCode:

class DropView:NSImageView {

    required init?(coder: NSCoder) {
        super.init(coder: coder)
        print("init") --> Displayed
        self.image=NSImage(named: "DropImage")
    }
}

However my DropImage (which returns a non-nil element) is not displayed on the ImageView. Am I missing anything ?

1

There are 1 answers

0
Willeke On

A Custom View in IB is just a NSView. NSImageView is a subclass of NSControl and needs a cell to function. Replace the Custom View by an Image View and change the class.