nscollectionview

NSCollectionView custom layout enable scrolling

拜拜、爱过 提交于 2020-01-31 05:27:29
问题 I can't get scrolling both vertically and horizontally to work with a custom layout for NSCollectionView. According to the docs, in my subclass I return the `collectionViewContentSize' and if that is too big, scrolling is automatically enabled in the enclosing scroll view of the collection view. However, even if I order all elements in a horizontal row, only vertical scrolling is enabled. Here is a screenshot: http://i.stack.imgur.com/tMbCN.png Here is my layout code: import Cocoa class

Cannot drag onto image in NSCollectionViewItem

[亡魂溺海] 提交于 2020-01-30 11:35:47
问题 I am designing a folder browser application similar to Finder. I want to enable users to drag files from outside the application and drop them onto a folder within my application, causing the dragged items to be added into that folder. My custom NSCollectionViewItem object, ArchiveCollectionViewItem , consists of a single NSImageView and a NSTextField . The image view is connected to the ArchiveCollectionViewItem 's imageView outlet and the text field is connected to the textField outlet. In

NSCollectionViewFlowLayout - left alignment

ε祈祈猫儿з 提交于 2020-01-12 09:17:46
问题 NSCollectionViewFlowLayout produces a layout with items justified on the right margin or, if the container is only wide enough for one item, centres items. I was expecting an alignment option, e.g. on the delegate, but am not finding anything in the docs. Does it require subclassing NSCollectionViewFlowLayout to achieve this? 回答1: Here is a subclass that produces a left justified flow layout: class LeftFlowLayout: NSCollectionViewFlowLayout { override func layoutAttributesForElementsInRect

NSCollectionViewFlowLayout - left alignment

你说的曾经没有我的故事 提交于 2020-01-12 09:17:40
问题 NSCollectionViewFlowLayout produces a layout with items justified on the right margin or, if the container is only wide enough for one item, centres items. I was expecting an alignment option, e.g. on the delegate, but am not finding anything in the docs. Does it require subclassing NSCollectionViewFlowLayout to achieve this? 回答1: Here is a subclass that produces a left justified flow layout: class LeftFlowLayout: NSCollectionViewFlowLayout { override func layoutAttributesForElementsInRect

Get the index of view from which a button was clicked in a NSCollectionView

人盡茶涼 提交于 2020-01-06 07:16:50
问题 I have a NSCollectionView and I am adding my custom view which acts as NSCollectionViewItem for that collection view. In my collectionViewItem, I have a NSButton along with various other elements. I have a method onButtonClick which is connected to that button. Now, suppose I add 5 items of my collectonViewItem on to the collectionView. How can I get the index of the view from where the button was clicked? Inside onButtonClick , I tried following code but it always returns 0 regardless of

Resize view of NSCollectionViewItem

早过忘川 提交于 2020-01-04 09:16:50
问题 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

Debugging Nested NSCollectionViews

﹥>﹥吖頭↗ 提交于 2020-01-02 06:23:11
问题 I'm not really sure how to start debugging this issue. I've got an NSCollectionView, whose NSCollectionViewItem prototype view itself contains an NSCollectionView (as well as an NSArrayController, to provide content to this 2nd-level collection view). Both levels of collection view work fine when the top-level view is in the main nib. However, when I copy/paste the view (and reconnect all the appropriate bindings) to a new nib, which I load with loadNibNamed:owner: , the 2nd-level view--but

Detect last visible nscollectionview item prototype

一曲冷凌霜 提交于 2019-12-25 06:59:29
问题 How is it possible to detect in NSCollectionView when the last item is visible on scrolling ? I was looking for a similar solution as this but NSCollectionView doesnt have a similar layout methods. Any hints ? 回答1: It is possible to get noted when the scroll view has scrolled by registering for boundsDidChange notification of the document view as described here Callbacks When an NSScrollView is Scrolled? . That way one can check which part of the content of the collection view is displayed.

NSCollectionView Master detail binding configuration

爷,独闯天下 提交于 2019-12-25 03:58:06
问题 I have the following models in my application. Board , holds a NSMutableArray property lists of type List below List , holds a NSArray property cards of type Card below Card , has a NSString property name The relationship is thus Board --> to-many List --> to-many Card I have a NSCollectionView based master-detail interface, where I want to display Boards in the master and its corresponding Lists+Cards in the detail view. The master interface is fine, the elements Board are displayed nicely.

NSPopover in NSCollectionView (or not)

强颜欢笑 提交于 2019-12-24 02:55:14
问题 I have a custom subclass of NSView that is used in an NSCollectionView . The view shows a NSPopover when it is double clicked using the code below: - (void)mouseDown:(NSEvent *)theEvent { [super mouseDown:theEvent]; if ([theEvent clickCount] == 2) { [popover showRelativeToRect:[self bounds] ofView:self preferredEdge:NSMaxYEdge]; } } popover is an IBOutlet (yes it's connected). This works fine when the view is placed in a window normally, but when the view is in the collection view, it doesn't