nstableview

What is the easiest way to custom NSTableView cell?

半世苍凉 提交于 2019-12-11 01:43:57
问题 I'm an iOS developer. I recently started my Mac project, but I found that unlike UITableViewCell, which is a subclass of UIView, the cell of NSTableView is NSCell, and I even can't create it in IB. I wonder if there are some easy ways to create subclass like NSTextFieldCell to put it into the NSTableView. Any help would be appreciated! Thanks! 回答1: Have a look at the open source PXListView class on Github This has a PXListViewCell that you can use as an example. 来源: https://stackoverflow.com

Custom background colors for NSTableCellView

爷,独闯天下 提交于 2019-12-11 01:43:39
问题 I am trying to create a custom NSTableCellView. I subclassed NSTableCellView and I need to have a custom background color and highlight/selection color. Is there a way to do this? 回答1: the background as well as the selection is handled by the NSTableRowView view. It CAN (partly) be overwritten by the cell but that's not how it should be at all. Implement a custom rowview and return that for use behind the row you need to draw @interface MyRowView : NSTableRowView there you have:

View based NSTableView with each view contains 3 labels with should resize based on Text

依然范特西╮ 提交于 2019-12-10 23:36:45
问题 I need to create a view based tableview in Popover as specified below: Tableview should be placed in Popover(Popover height should be same as tableview). Each row should contain a view. Each row view will contain 3 labels. Labels should be auto re sizable based on its text height. Based on 3 labels height, Cell row height should resize. Based on all cell rows, tableview height should resize. Based on tableview height, Popover should resize. I have done this in a static format, but i need to

NSTableView Cell with Identifier keep giving nil

℡╲_俬逩灬. 提交于 2019-12-10 18:51:15
问题 I am working on building MacOS app. I am trying to make table view that updates the cell when I press add button. Following is my code: func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { let identifier = tableColumn?.identifier as NSString? if ( identifier == "NameCell") { var result: NSTableCellView let cell = tableView.make(withIdentifier: "NameCell", owner: self) as! NSTableCellView cell.textField?.stringValue = self.data[row].setting!

NSTableView redraw not updating display, selection sticking

我的梦境 提交于 2019-12-10 15:46:13
问题 Although I know of a solution to this problem, I am interested if someone can explain this solution to me. I also wanted to get this out there because I could not find any mention of this problem online, and it took me several hours over several days to track down. I have an NSTableView behaving strangely regarding redraws and its selection. The problem looks like this: Table contents fades in, instead of appearing instantly upon it's appearance on screen. When scrolling through the contents,

How to bind data to a NSTableView from a NSDictionary?

笑着哭i 提交于 2019-12-10 13:49:21
问题 Does anybody knows how to fill up a NSTableView using binding values from a NSDictionary? Thanks in advance. 回答1: You need to create an NSDictionaryController in Interface Builder. Bind it to your dictionary, and then bind the NSTableView to the objects in the NSDictionaryController . Look here: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSDictionaryController_Class/Introduction/Introduction.html If you don't yet fully understand Cocoa Bindings and KV coding, you

Get selected column and row from NSTableView

爱⌒轻易说出口 提交于 2019-12-10 11:36:54
问题 I have a table with 2 columns. And for each column am populating data from an unique array which is contained in a dictionary. So now when I click on a row in second column, its not possible to extract data from the dictionary as I dont get Column selected, but only row. [tableView selectedColumn] //returns -1 [tableView selectedRow] //returns 1, but I needed the column number as well so I could pick the array from dictionary. How can I get the column selected ? 回答1: If you look in

View based NSTableView viewForTableColumn:row not called

岁酱吖の 提交于 2019-12-10 10:52:15
问题 I've got a View-based NSTableView which is configured in IB to be View based. Its column identifier is set, too. As are its dataSource and delegate set, to the same object, which claims to conform to both in the public header. I've verified these are set after the tableView awakes from its nib. As per the docs, I've implemented -numberOfSectionsInTableView: and it gets called and returns a non-zero number. However, -tableView:viewForTableColumn:row: , much to my chagrin, does not, and I can't

How to place an NSButton over an NSTableView

你。 提交于 2019-12-10 08:31:16
问题 1) No table behind button 2) Table loaded 3) After scrolling If I place a button over an NSTableView I get artifacts being left behind after scrolling. Does anyone know how to fix this? My current solution is just to split the section with the table into 2. The lower portion is a disabled button in the background. 回答1: I had a similar problem and solved it, see Why does an NSTextField leave artifacts over an NSTableView when the table scrolls?. Essentially OSX will draw the contents of the

Layout still needs update after calling NSTableRowView layout

…衆ロ難τιáo~ 提交于 2019-12-10 05:58:55
问题 I have two NSTableView's in my app and the user can drag and drop items from table A to table B. When dragging an item to table B Xcode gives me the following layout warning message: Layout still needs update after calling -[NSTableRowView layout]. NSTableRowView or one of its superclasses may have overridden -layout without calling super. Or, something may have dirtied layout in the middle of updating it. Both are programming errors in Cocoa Autolayout. The former is pretty likely to arise