View based NSTableView having Sluggish Scrolling - cocoa

I am using View based NSTableView where I have around 30 columns and rows could be in between 200 - 1000. The problem is that the tableView is very sluggish. After doing some debugging, I figured out that adding an identifier to NSTableCellView made the scrolling super fast. But the problem arose that no data was displayed. Since all the data being displayed to the columns is using binding, so no code has been written for it. Now, I am not able to figure it out why is that happening or what is the correct way of using view based NSTableView using binding and reusing Cells. Could someone provide me some highlights on how to make the scrolling smooth for such scenarios.

Related

NSTableView as a form - nextKeyView issue (or how to force load all rows)

Perhaps using an NSTableView as a form is a terrible idea, but I've got it working pretty well in every respect except that you can't tab from field to field.
I have a table with a label column and a field column. I also have an array that keeps track of each row in the table with its accompanying NSTextField control. The controls are set in the array as they are loaded during tableView(tableView: viewForTableColumn: row:).
After the tableview is drawn, I run through each control in the array and set its nextKeyView to the following control.
This works swell, BUT only for those controls which have been displayed on screen. Because the control isn't added until it's loaded, table rows which are off-screen aren't hooked up.
My current approach (which is awful) is to manually scroll the table several times in order to force everything to load, then set all the nextKeyViews. I haven't got it working very well yet, so I was hoping someone had a better idea. Force-loading all views, if it works, should be an OK solution, but there may be something smarter out there too.
I guess the answer is
table.scrollRowToVisible(<row>)
This will show the row you want to see.

Single cell selection NSTableView

There are a few google results for this question but they are ancient and didn't really help. So I'm asking again for modern uses, how can I set up selection for a single row and column. Like the Numbers app. So the row/column its self is not highlighted but the focus ring is drawn for the row, column that was selected.
I'm open to Cell based or View based implementation. I have tried doing things inside the
- (void)tableViewSelectionDidChange:(NSNotification *)notification
but haven't been able to get things working or looking nice.
Has anyone done this, is there a better view architecture for this?

How to correctly add NSComboBox to view-based NSTableView in Interface Builder

I'm basically asking how do you correctly add a Combo Box to a Table View with correct layout i.e. so that appears as if you were adding a ComboBox cell to a cell-based Table View. Currently when I add it to the Table Cell View it doesn't fit (bottom half chopped off) and doesn't behave as its supposed i.e. focus ring is messed up, arrows messed up, not aligned correctly.
I have searched the net couple of times over and funny enough I haven't found an answer to this question. If I don't find a solution I might have return to good old cell-based table views.
If the combo box doesn't fit, you need to increase the height of the NSTableCellView. This is done in Interface Builder or, if implemented, in the NSTableViewDelegate method tableView:heightOfRow:.

UITableView like NSTableView

Ive developed for iOS in the past and recently moved over to mac development. I began a project to "get the feel" of things, and ran into an issue. Im trying to create a NSTableView to display multiple items, including a label, a 2 UIImageViews, and a UIButton. NSTableViews are way different than tables on iOS, and I cant simply create a custom TableViewCell (I think). A great example of how I would like it to look is AlienBlue for Mac: (The middle table with post information)
Can anyone shed some light on how to create this?
You have the power of being able to return whole views instead of cells in NSTableViews.
Here's Apple's documentation on View-based tables and how to populate those views in your table.
The delegate method I use most in my own view-based tables is "tableView:viewForTableColumn:row:"
Hopefully this points you in the right direction!
Please use NSCollectionView instead (set NSCollectionView.maxNumberOfColumns = 1). It's a more modern, extensible view api, that is analogous to UICollectionView.
In contrast, NSTableView was originally meant for displaying a spreadsheet table (with add-on support for custom view cells), and is less consistent with UITableView.

NSTableView redraw not updating display, selection sticking

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, the newly appearing rows also fade in. When you make a selection (single or multiple), and scroll it off screen, then make another selection (that should replace, not add-to first selection), the first selection does not get cleared properly. If you scroll back to it, it is still there, in addition to your new selection. This is a display-update problem, not selection problem - i.e. your new selection is valid, it is just displayed wrong.
I tracked this through the NSArrayController I was binding to, the underlying Array, sorting, all the connections, and settings, etc., but all that has nothing to do with it.
What solved the problem was:
In the View Effects (right-most) Inspector, uncheck "Core Animation Layer" for the Window's main view.
Can anyone explain what is happening here, and perhaps improve upon the solution ?
It looks like Core Animation and NSTableView aren't getting along so well. The "fading" effect is a by-product of the way core animation works. When you have core animation in one view, it is also enabled in all of that view's subviews.
I don't recommend using core animation on the Mac unless absolutely necessary, because some interface elements (NSTextView and NSTableView, for example) aren't compatible with it. iOS has much better support for table views and such using core animation, mainly because it was designed with core animation in mind.
I know that some more simple UI elements are compatible (NSTextField and NSButton, for example).
If you absolutely need core animation in the rest of the window, put all the other views in a subview of the content view, while leaving the table view directly in the content view. You can then enable Core Animation in the other view.
Commenters, feel free to add to the list of what is and isn't compatible.

Resources