nscollectionviewitem

Resizing NSCollectionView to fit inner items?

落爺英雄遲暮 提交于 2019-12-04 19:12:55
How can I resize my NSCollectionView to fit the size of all my items ? I tried something like that : float height=0; for(int i=0;i<[drives count]; i++) { height += [[[collectionView itemAtIndex:i] view] bounds].size.height; } NSLog(@"%lg", height); [[self view] setBoundsSize:NSMakeSize(300, height)]; and all I got was a horrible result : the collectionView was distorted. It was previously smaller than the parent view and with that it expanded to fill the parent view. NB : I removed the scrollbars of the collection view and inner items are NSBox. Ps : this what I have without any resizing ;

NSCollectionViewItem never instantiate

不羁的心 提交于 2019-12-04 01:38:25
问题 I'm a bit lost here: I created a button acting like a colorPicker: clicking on it shows a collectionView in a popover. I first did it with a nib fil containing a view + the collectionView (embedded in as scrollView + a clipView). The stuff works just fine. As the nib file is very simple (and to improve my coding skills in designing views programmatically), I decided to get rid of the nib file and write the missing part in code. The thing is, I manage to get the job done except for the content

10.11 NSCollectionView - determining cell size dynamically

故事扮演 提交于 2019-12-03 12:28:01
问题 AppKit Release Notes for OS X v10.11 suggests that collection view items can be resized on a per-item basis: Item size can be determined globally for all of a CollectionView’s items (by setting an NSCollectionViewFlowLayout’s “itemSize” property), or can be varied from one item to the next (by implementing -collectionView:layout:sizeForItemAtIndexPath: on your CollectionView’s delegate). In my case, my CollectionViewItem consists of a single label that contains a string of varying length. I'm

10.11 NSCollectionView - determining cell size dynamically

爱⌒轻易说出口 提交于 2019-12-03 02:53:07
AppKit Release Notes for OS X v10.11 suggests that collection view items can be resized on a per-item basis: Item size can be determined globally for all of a CollectionView’s items (by setting an NSCollectionViewFlowLayout’s “itemSize” property), or can be varied from one item to the next (by implementing -collectionView:layout:sizeForItemAtIndexPath: on your CollectionView’s delegate). In my case, my CollectionViewItem consists of a single label that contains a string of varying length. I'm using the NSCollectionView to display an array of strings, as NSStackViews don't support array

Custom outlets in NSCollectionViewItem subclass

笑着哭i 提交于 2019-12-01 11:33:13
I feel this being a simple task, but I don't seem to be able to make it work. I'm trying to have a NSCollectionView with custom items. I added another NSImageView to the custom view of the item, and I subclassed this view in order to add the custom outlet connected to this additional NSImageView. Now I am overriding - (NSCollectionViewItem *)newItemForRepresentedObject:(id)object because sometimes I need to remove this NSImageView. - (NSCollectionViewItem *)newItemForRepresentedObject:(id)object { CustomItem *theItem = (CustomItem *)[super newItemForRepresentedObject: object]; ... if (I need

Custom outlets in NSCollectionViewItem subclass

时光毁灭记忆、已成空白 提交于 2019-12-01 09:18:08
问题 I feel this being a simple task, but I don't seem to be able to make it work. I'm trying to have a NSCollectionView with custom items. I added another NSImageView to the custom view of the item, and I subclassed this view in order to add the custom outlet connected to this additional NSImageView. Now I am overriding - (NSCollectionViewItem *)newItemForRepresentedObject:(id)object because sometimes I need to remove this NSImageView. - (NSCollectionViewItem *)newItemForRepresentedObject:(id

NSCollectionViewItem never instantiate

隐身守侯 提交于 2019-12-01 06:38:26
I'm a bit lost here: I created a button acting like a colorPicker: clicking on it shows a collectionView in a popover. I first did it with a nib fil containing a view + the collectionView (embedded in as scrollView + a clipView). The stuff works just fine. As the nib file is very simple (and to improve my coding skills in designing views programmatically), I decided to get rid of the nib file and write the missing part in code. The thing is, I manage to get the job done except for the content of the collectionView. After deep investigation, it appears that, inside the method: func

Cocoa - Where is the link between a NSCollectionView and a NSCollectionViewItem? Xcode 6 Bug?

淺唱寂寞╮ 提交于 2019-11-29 21:46:53
When you drag a NSCollectionView to a view, a NSCollectionViewItem appears on the storyboard, floating around. Imagine I drag several NScollectionViews to the same view. I will have a bunch of NSCollectionViewItems. How a collection view knows which NScollectionViewItem belongs to it? Is there a connection between the two that can be seen on interface builder? I don't see anything on interface builder? Where to do I see that? EDIT: Apparently this seems to be a Xcode bug. When you add a NSCollectionView to the storyboard, it comes without a link to the NSCollectionViewItem and it seems to be

Cocoa - Where is the link between a NSCollectionView and a NSCollectionViewItem? Xcode 6 Bug?

一笑奈何 提交于 2019-11-28 17:33:20
问题 When you drag a NSCollectionView to a view, a NSCollectionViewItem appears on the storyboard, floating around. Imagine I drag several NScollectionViews to the same view. I will have a bunch of NSCollectionViewItems. How a collection view knows which NScollectionViewItem belongs to it? Is there a connection between the two that can be seen on interface builder? I don't see anything on interface builder? Where to do I see that? EDIT: Apparently this seems to be a Xcode bug. When you add a

Get the representedObject values of NSCollectionViewItem NSButton click

为君一笑 提交于 2019-11-28 11:50:17
I have read some questions and I find some very confusing and I don't really know if they answer my question. I have an NSCollectionView implemented and connected to a Core Data context , everything shows correctly. Now what I have is buttons in the view prototype , and when I click this buttons I need to get the value of the representedObject of that cloned view. I have read and read and some parts are confusing to me, so I'm looking for a simple explanation. Thank you for your time. An action method takes one argument: - (IBAction) collectionViewButtonClicked:(id)sender { } That sender is