nscollectionview

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

NSCollectionView with sections - like in iPhoto

血红的双手。 提交于 2019-11-30 13:20:58
问题 I'd like to build a NSCollectionView similar to the one in iPhoto '11. I want to group several pictures in section, and create a section header as well. The section header of a specific section is always visible until the last element of that section is visible. You can take a look at the picture to see what I mean. EDIT: I should add that the contents are not images. Thanks in advance 回答1: You're probably going to have to look at using CALayers directly. NSCollectionView gets most of its

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

Can NSCollectionView autoresize the width of its subviews to display one column

蓝咒 提交于 2019-11-29 04:07:15
I have an NSCollectionView that contains a collection of CustomViews . Initially it tiled the subviews into columns and rows like a grid. I then set the Columns property in IB to 1, so now it just displays them one after another in rows. However, even though my CustomView is 400px wide, it's set to autoresize, the NSCollectionView is 400px wide, and it's set to 1 column, the subviews are drawn about 80px wide. I know I can get around this by calling: CGFloat width = collectionView.bounds.size.width; NSSize size = NSMakeSize(width, 85); [collectionView setMinItemSize:size]; [collectionView

Is there a way to set up a NSCollectionView programmatically in Swift?

血红的双手。 提交于 2019-11-29 00:11:20
I'm coming from the iOS development and I am wondering if there is a way to set up a NSCollectionView programmatically like a UICollectionView in iOS? And add the NSCollectionViewItems in code. Or is the only way to set up a NSCollectionView to use bindings? Thank You! stefOCDP Thanks to @stevesliva for pointing me to this SO answer . I converted it to Swift. This is what I got. I am creating a NSCollectionView in the ViewController: import Cocoa class ViewController: NSViewController { var titles = [String]() var collectionView: NSCollectionView? override func viewDidLoad() { super

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

How to create NSCollectionView programmatically from scratch?

大憨熊 提交于 2019-11-28 17:00:48
NSCollectionView remains one of the most mysterious parts of the Cocoa API that I've ever seen. Documentation is poor and there are many moving parts, many of which are often implemented in Interface Builder, making documentation challenging. Please provide sample code to create the simplest case of NSCollectionView which displays either Text Fields or Buttons without using Xcode where each Text Field or Button has a different Title. Assume a new Xcode project with the default window IBOutlet. For this example, no binding is required to update the NSCollectionView as the data source changes.

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