nscollectionview

Equivalent of ReloadData for NSCollectionView to redraw item views

為{幸葍}努か 提交于 2019-12-11 06:57:58
问题 I have a toggle to change the font attributes. In my NSOutlineView, I call ReloadData to have everything re-render. However, how can I force NSCollectionView to re-render. I tried cvReader.NeedsLayout= true; cvReader.Layout(); cvReader.NeedsDisplay = true; cvReader.Display(); to no avail. Any hints much appreciated. Update. I also tried cvReader.NeedsDisplay = true; cvReader.Window.ViewsNeedDisplay = true; cvReader.Window.FlushWindowIfNeeded(); As well as assigning the content again. It feels

NSCollectionView cell order changes on view change

白昼怎懂夜的黑 提交于 2019-12-11 02:14:29
问题 I have a macOS application that contains a tab bar design (ie: Tweetbot). There are 4 tabs that are linked to 4 different view controllers. The initial view controller (view one) contains a NSCollectionView which displays 3 cells horizontally. This all works fine, however when I switch to another view controller and then come back to the initial view controller, the order of the collection view changes for no reason. I am not making ANY changes to the data source (which is a NSMutableArray )

Creating NSCollectionView with datasource programmatically

a 夏天 提交于 2019-12-11 00:50:04
问题 I am trying to create a NSCollectionView programmatically using a NSCollectionViewDataSource . The code is very simple: self.collectionView = [[NSCollectionView alloc] init]; // Add collection view to self.view etc. self.collectionView.dataSource = self; [self.collectionView registerClass:[NSCollectionViewItem class] forItemWithIdentifier:@"test"] self.collectionView.collectionViewLayout = gridLayout; [self.collectionView reloadData] This leads to the following methods getting called (if I

NSCollectionView deselect multiple selection

拥有回忆 提交于 2019-12-10 11:25:07
问题 So I've been investigating on this topic now for quite a bit, but haven't found anything useful related to it. My problem is that I created an NSCollectionView that serves like an image handler, so where you can drop images, select one or even multiple images at a time and delete them if wanted. Selecting the pictures was rather easy and I achieved it with this bit of code: func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>) { selectedCells =

Binding to NSCollectionViewItem crashes Xcode

吃可爱长大的小学妹 提交于 2019-12-10 10:13:20
问题 Using XCode 4.1 I've come across a crash whenever I try to use a CollectionView. These are the steps I'm doing: From a new project, edit the MainMenu.nib file. Add an NSCollectionView to the window, which also adds a Collection View Item, and a new View In the new View Add a control like an NSTextField Select the control, and switch the inspector to the binding pane. Attempt to bind something to the Collection View Item. Once the Collection View Item is selected in the dropdown menu, an

How to Color the “Overshoot” Background of an NSCollectionView

十年热恋 提交于 2019-12-10 10:07:34
问题 I have implemented a collection view on my Cocoa app following Ray Wenderlich's tutorial (very helpful, given how buggy and broken Apple's API is in this area). In the tutorial, the collection view's canvas is colored black using the following code (all code is in view controller class' viewDidLoad() method): collectionView.layer?.backgroundColor = NSColor.black.cgColor However, the area that "peeks" when you overshoot ("rubber-band") the scroll using -for example- a magic mouse/scrollwheel,

Resizing NSCollectionView to fit inner items?

我的未来我决定 提交于 2019-12-09 23:31:50
问题 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

NSCollectionView Drag and Dropping: Most Delegate Events Not Getting Called

不羁的心 提交于 2019-12-09 18:01:13
问题 I have an NSCollectionView bound to an NSArrayController. I want to get drag and drop working, so I create a delegate and implement the methods -(BOOL)collectionView:(NSCollectionView *)collectionView canDragItemsAtIndexes:(NSIndexSet *)indexes withEvent:(NSEvent*)event -(BOOL)collectionView:(NSCollectionView *)collectionView acceptDrop:(id < NSDraggingInfo >)draggingInfo index:(NSInteger)index dropOperation:(NSCollectionViewDropOperation)dropOperation -(NSDragOperation)collectionView:

Transparent NSCollectionView Background

99封情书 提交于 2019-12-09 17:25:37
问题 I'm again struggling with setting NSViews background colors to transparent. I have a NSCollectionView as part of NSClipView which is part of a NSScrollview . My MainViewController has an outlet to the collectionView . With adding the two lines of code and after compiling the background is sometimes transparent but most of the times not: view.wantsLayer = true collectionView.layer?.backgroundColor = NSColor.clear.cgColor I also tried to select/de-select the "Draw Background" property of the

collectionView(_:didDeselectItemsAt:) is never called

自古美人都是妖i 提交于 2019-12-08 09:38:50
问题 For some reason, my NSCollectionView (which uses a custom layout that I wrote) calls its delegate's collectionView(_:didSelectItemsAt:) function when I click an item, but not that same delegate's collectionView(_:didDeselectItemsAt:) when I click off it. Here's my basic setup: class MyCollectionViewContainer: NSViewController { fileprivate lazy var collectionView: NSCollectionView = { let collectionView = NSCollectionView() collectionView.delegate = self collectionView.dataSource = self