2

How do I programatically set the size of a view of an NSCollectionViewItem?

I tried doing this in an NSCollectionView subclass:

@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 subclassing my NSView that I use for the NSCollectionViewItem, and adding setFrame: to the initWithCoder method, but I get an EXC BAD ACCESS crash when I do that.

indragie
  • 18,002
  • 16
  • 95
  • 164

1 Answers1

0

You might checkout this open source NSCollectionView alternative from Steven Degutis which, coincidentally I think was just posted to GitHub today (I noticed it today via Twitter):

http://github.com/sdegutis/SDListView

Looks like it allows you to have items with different heights.

Todd Ditchendorf
  • 11,217
  • 14
  • 69
  • 123
  • ..that link's not working anymore (12/2011) but there's a mirror at https://github.com/arbales/SDListView – Jay Dec 12 '11 at 06:04