Binding a custom NSView: Does it demand creating an IBPlugin?

前端 未结 4 1141
闹比i
闹比i 2021-02-19 09:01

I have created a subclass of NSView to draw an image as a pattern:

@interface CePatternView : NSView
{
    NSImage*    image;
    id      observableObjectForImag         


        
4条回答
  •  臣服心动
    2021-02-19 09:32

    If you can manage to do the bindings manually you will save yourself a lot of time. Creating custom IB palettes is a lot of work compared to a few lines of manual binding code. But, if your needs require a custom IB palette then I would start by reviewing what the NSView subclass will require, coding-wise. A great place to start looking is Crawford's website on bindings:

    http://homepage.mac.com/mmalc/CocoaExamples/controllers.html

    I've used it a lot over the past couple years, it has helped a lot with my custom IB palette objects and with binding issues in general. There is an example on his site specifically detailing custom NSView's with custom bindings.

    Something else to note, is that your custom view will also have to work in the Interface Builder environment. There are a few small fixes that need to be put into place in your bindings code in your custom NSView object so that it functions and binds properly in Interface Builder. These details are also noted on Crawford's site:

    http://homepage.mac.com/mmalc/CocoaExamples/controllers.html#ibBindings

提交回复
热议问题