简体   繁体   中英

Bindings for custom views for NSCollectionViewItem

I've got a NSCollectionView bound to my array of model objects, the NSView prototype to render items of the collection view is set up to use my custom NSView subclass.

At runtime a (generic) view is shown/instantiated in the collection view for each array element, all good.

However, I just can't figure out how to get to my array objects from the individual view instances to render the actual data that's specific to each element in the array.
Ie how are we supposed to hook up data to the NSView prototype that is used to configure a 'cell' in the collection view?

  • Outlets don't seem to work for that particular view; they're all nil at runtime.

  • Bindings don't work with a vanilla NSView (apart from hidden and tooltip bindings for vanilla views..) - and we cannot add new bindings that would show up in IB for our NSView subclasses, can we?

Any hint appreciated!

Nevermind - I've settled with a custom NSCollectionView class overriding only

- (NSCollectionViewItem *)newItemForRepresentedObject:(id)object

to access the item view of NSCollectionViewItem instances created by super and set the required property there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM