nscollectionview

View-based NSTableView vs NSCollectionView?

为君一笑 提交于 2019-12-22 05:23:29
问题 I've understood the fly-weight approach of cell-based NSTableView and I think I understand the differences with NSCollectionView. Differences between (cell-based) NSTableView and NSCollectionView However, a bit less obvious is the differences between view-based NSTableView and NSCollectionView. With NSCollectionView's flexibility in displaying its items (i.e. in a grid layout) which could emulate a tableView's list (a grid with maximum one column) and excluding personnal preferences, why

NSCollectionView How to scroll to selected item

我们两清 提交于 2019-12-21 20:37:46
问题 I programmatically select a item in my NSCollectionView. The item is selected as expected but the view doesn't scroll automatically to this item. [collectionView setSelectionIndexes:[NSIndexSet indexSetWithIndex:compt]]; How to scroll to the selected item ? 回答1: Find the answer here NSScrollView: Make sure frame is visible This code worked for me : NSRect selectionRect = [self.collectionView frameForItemAtIndex:[[self.collectionView selectionIndexes] firstIndex]]; [self.collectionView

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

六眼飞鱼酱① 提交于 2019-12-18 04:12:30
问题 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

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

别说谁变了你拦得住时间么 提交于 2019-12-18 04:12:05
问题 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

Selection Highlight in NSCollectionView

好久不见. 提交于 2019-12-17 17:37:23
问题 I have a working NSCollectionView with one minor, but critical, exception. Getting and highlighting the selected item within the collection. I've had all this working prior to Snow Leopard, but something appears to have changed and I can't quite place my finger on it, so I took my NSCollectionView right back to a basic test and followed Apple's documentation for creating an NSCollectionView here: http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/CollectionViews

NSCollectionView selection handling in Swift

让人想犯罪 __ 提交于 2019-12-12 12:21:57
问题 Learning with Swift and I've been at this all day with little progress: Need to know when an item in NSCollectionView is selected. The end goal is to get the item to highlight and to be able to delete it from the collection with the delete key. My NSCollectionView is bound to an ArrayController to get content and send the selection indexes, so looks like I need to be watching the ArrayController for a selection change, but don't see any helpful delegate methods there. The prototype view has a

Is there a way to have varying views in an NSCollectionView?

╄→гoц情女王★ 提交于 2019-12-12 08:07:52
问题 I am wanting something similar to how iWork has the template selection screen for Pages when you can select different templates, and each view contains different info has difference sizes etc. I have tried subclassing NSCollectionView and determining which view to display using the newItemForRepresentedObject method (as opposed to using itemPrototype view Interface Builder), but it for some reason doesn't position the views correctly, and it does not show the correct number of views for the

NSCollectionView loses scrollbars after changing minItemSize until view gets resized

醉酒当歌 提交于 2019-12-11 16:21:56
问题 I have an NSCollectionView with a vertical NSCollectionViewFlowLayout . I display rectangular icons in it. I also have a slider in the UI, and when that changes, I adjust the minItemSize , which I then use in collectionView:itemForRepresentedObjectAtIndexPath: to create an equally sized NSImageView to the returned NSCollectionViewItem 's imageView . Then I reload the view by invoking reloadData . After that, the view shows the icons in the new size as intended. The problem is, provided I have

NSCollectionViewItem behind a NSTextField

时光毁灭记忆、已成空白 提交于 2019-12-11 15:36:13
问题 I have a NSTextField on the view of an NSCollectionViewItem . When you click an NSCollectionViewItem the item is selected. When you click the NSTextField it gains focus, but the NSCollectionViewItem which is behind the text field does not get selected. I want to change this last behaviour so the text field gets focus and the view item also gets selected. What's the best way to do this? 回答1: I believe you would have to subclass NSTextField and override mouseDown to pass the event to the

NSCollectionView inside another NSCollectionView

梦想与她 提交于 2019-12-11 13:00:17
问题 I have these two classes: @interface Father : NSObject { NSString* name; NSArray* listChildren; } @property (copy, readwrite) NSString* name; @property (copy, readwrite) NSArray* listChildren; @end @interface Child : NSObject { NSString* nameChild; NSImage* picture; } @property (copy, readwrite) NSString* nameChild; @property (copy, readwrite) NSImage* picture; @end I'm trying to make a NSCollectionView filled with Father items, and for each father item's View i will have a name label, and