Resizing NSCollectionViewItem

How can I program the size of the NSCollectionViewItem?

I tried to do it in a subclass of NSCollectionView:

@implementation CustomCollectionView

- (NSCollectionViewItem *)newItemForRepresentedObject:(id)object {

    NSCollectionViewItem *newitem = [[self itemPrototype] copy];
    [newitem setRepresentedObject:object];  
    NSView *itemview = [newitem view];
    [itemView setFrame:NSMakeRect([itemView frame].origin.x, [itemView frame].origin.y,         [itemView frame].size.width, 500)];
    return newitem;
}

@end

      

However, this code has no effect. I tried to subclass my NSView which I am using for the NSCollectionViewItem and adding setFrame: to the initWithCoder method, but I get EXC BAD ACCESS error when I do that.

+2


source to share


1 answer


You can check out this open source NSCollectionView alternative from Steven Degutis, which I think has been pushed to GitHub by now (I noticed this today via Twitter):

http://github.com/sdegutis/SDListView



It looks like it allows you to have elements with different heights.

0


source







All Articles