nstableview

How can I add a footer view to NSTableView?

邮差的信 提交于 2019-12-08 17:06:01
问题 It seems that NSTableView has no equivalent to UITableView 's tableFooterView property. What is the preferred way to add a footer view to a table view in Cocoa? 回答1: NSTableView doesn't have sections like UITableView or NSCollectionView, and therefore no headers and footers. Instead you can do it via your datasource, if you are using a view-based table. Add a cell to your table in Interface Builder with custom styling/elements that you need in your footer. Give it an identifier like

Warning “Implicit conversion loses integer precision…”

南楼画角 提交于 2019-12-08 16:15:11
问题 I am doing a shopping cart tutorial: I have an array that collects input from a text field, and then displays it in the NSTableView. You can check an item, and remove it from the list. I want to display a warning only if something is checked. So, I have this: -(IBAction)removeItemFromShoppingList:(id)sender { int selectedItemIndex = [shoppingListTableView selectedRow]; if (selectedItemIndex == -1) return; NSAlert *alert = [[NSAlert alloc] init]; ... [alert runModal]; [alert release]; } On

Display icon and text in same cell of NSTableView

余生长醉 提交于 2019-12-08 07:53:33
问题 I would like to display an icon next to a text item in an single cell of a table view. An example of what I want to achieve is the application list in System Preferences -> User Accounts -> Login Items. What's a good way? 回答1: There is a good example here how to do it: http://www.cocoadev.com/index.pl?IconAndTextInTableCell You make your own custom NSCell that both draws a image and text @interface IconCell : NSCell { NSArray * cellValue; } - (void)setObjectValue:(id <NSCopying>)object; -

Programmatically update a TableView that is governed by Cocoa Bindings

北战南征 提交于 2019-12-08 07:37:50
问题 I'm fairly new to obj-c and cocoa so please bear with me: I have a NSTableView set up with cocoa bindings which works as expected with the simple -add -remove, etc methods provided by an instance of NSArrayController in my nib. I would like to programmatically add objects to the array that provides content for this controller (and hence for the table view) and then update the view accordingly. I current have a working method for adding a new object to the array (verified by NSLog) but I can't

NSTableView: only numberOfRowsInTableView: datasource is called

拜拜、爱过 提交于 2019-12-08 07:32:37
问题 I met a problem about the NSTableView , and it is like: one datasource of tableview is called: - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { return [self.dataArray count]; } But this one is never called: - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { // the code } I have checked the the array really had data, and also checked the [NSTableView reloadData] was called in the main thread. SO I'm totally lost

How to do collapse and expand view in mac application?

橙三吉。 提交于 2019-12-08 07:21:05
问题 I am new to mac application development, here i want to do expand and collapse view in my custom view(NSView) here the sample image How can i achieve these kind of collapse and expand cell in NSViewController not in NSWindow... Is it possible using NSTableView? I know its a simple question but i facing problem. Please suggest me some sample code or links.. Thanks 回答1: Collapsing / expanding can be implemented by adjusting auto layout constraints in the action method of the disclosure triangle

Programmatically update a TableView that is governed by Cocoa Bindings

萝らか妹 提交于 2019-12-08 07:06:31
I'm fairly new to obj-c and cocoa so please bear with me: I have a NSTableView set up with cocoa bindings which works as expected with the simple -add -remove, etc methods provided by an instance of NSArrayController in my nib. I would like to programmatically add objects to the array that provides content for this controller (and hence for the table view) and then update the view accordingly. I current have a working method for adding a new object to the array (verified by NSLog) but I can't figure out how to update the table view. So: How do I update the bound tableview? (ie, after I have

How can I sort an NSTableColumn of NSStrings ignoring “The ” and “A ”?

喜你入骨 提交于 2019-12-08 06:32:07
问题 I've got a simple Core Data application that I'm working on to display my movie collection. I'm using an NSTableView , with it's columns bound to attributes of my Core Data store through an NSArrayController object. At this point the columns sort fine(for numeric values) when the column headers are clicked on. The issue I'm having is with the String sorting, they sort, however it's done in standard string fashion, with Uppercase letters preceding lowercase(i.e. Z before a). In addition to

NSButton gets drawn inside custom NSCell, but is not actually clickable

半腔热情 提交于 2019-12-08 06:01:43
问题 I have a NSTableView which contains my custom NSCell subclass, IconCell. The IconCell contains three elements : an image, text, and a button. Here's a simplified version of my drawing code ( closeButton is the button): - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { NSPoint cellPoint = cellFrame.origin; [controlView lockFocus]; CGFloat buttonWidth = [closeButton frame].size.width; [someNSImage drawInRect:NSMakeRect(cellPoint.x, cellPoint.y, ICON_WIDTH, ICON

NSButton gets drawn inside custom NSCell, but is not actually clickable

时间秒杀一切 提交于 2019-12-08 05:37:41
I have a NSTableView which contains my custom NSCell subclass, IconCell. The IconCell contains three elements : an image, text, and a button. Here's a simplified version of my drawing code ( closeButton is the button): - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { NSPoint cellPoint = cellFrame.origin; [controlView lockFocus]; CGFloat buttonWidth = [closeButton frame].size.width; [someNSImage drawInRect:NSMakeRect(cellPoint.x, cellPoint.y, ICON_WIDTH, ICON_HEIGHT) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil];