NSTableView doesn't update after sorting via column header - objective-c

I have an NSTableView bound to a core-data-backed NSArrayController by binding individual columns to arraycontroller.arrangedObjects.
I have the default out-of-the-box sorting working, but when I click one of the column headers to sort the table I have problems.
Basically the display of the table gets messed up: rows get duplicated, and the sort order is all over the place.
However, when I click on a row the TableView redraws and everything looks fine.
So, it looks like the sorting is working properly, but it is not being reflected in the display of the tableview until I click on a row.
Can anyone tell me why my tableview isn't updating properly when I sort?
I have Googled this extensively, looked in the docs, and tried everything I can think of in the code but can't work out what is happening.
Thanks
Darren.

The problem was very simple in the end.
For some reason I had ticked the "Core Animation" layer selector for the TableView, which was causing the display to be garbled.
When I cleared the tickbox everything started working properly.
Regards
Darren.

Related

NSTableView Layout issue with Highlight and Background Color

I am basically trying to recreate the popOver that exists in certain Xcode Settings, like this one in Build Settings:
I have tried both with and without using an NSArrayController to control the content but in each of the tests I ran in to different problems I haven't been able to solve.
Desired Result
Complete White Background
Multiple Selection and (Single) Editable Cells
No Reordering is required
When I press the + button I want the new cell to be selected and in edit mode
I want to get notification of when text changes while editing to be able to respond to that.
1. Using Delegate Methods.
When I had set up everything up I got this result:
That didn't look good, so I went and selected "Draws Background" for the NSTableViewCell, which resulted in this which looks nice when I edit a cell:
But when i just Highlight the cell, it looks like this:
It looks like the highlighting get's placed behind the cell background.
Here I'm stuck and don't know how to fix.
2. Using NSArrayController
When I reconfigure and bind this to an NSArrayController the highlighting looks great:
But when I edit a cell, the entire background changes to grey:
This is also not what I want, but can't figure out what to do about.
--
Notes
In Desired Result I listed some things like "When I press the + button I want the new cell to be selected and in edit mode" and "I want to get notification of when text changes while editing to be able to respond to that." To possibly influence the choice of what route to take, as there are more things about thins TableView I haven't figured out.
But this question Is all about how to fix the highlighting and selection so they stay white all the time, and just selecting a cell looks as expected.
Example Code
Example code for the Delegates Method version:
https://github.com/erikberglund/StackOverflow/tree/master/TableViewDelegates
Example code for the Bindings version:
https://github.com/erikberglund/StackOverflow/tree/master/TableViewBindings
Force the appearance to aqua. So instead of inherited select aqua. This solved the issues for me.

Window doesn't render as expected, controls gets messed up

I have a NSWindow with autolayout, There is one view based NSTableView with few controls like images and labels . Once in a while the window comes ugly, means all the constraints doesn't work, and the text fields, images just loose their places.
All the controls inside the tableView are seen in (0,0). But only for few rows, for other rows it work perfectly, however all rows contains same controls.
This is happening only for the first time specially in OSX 10.10 when installing from DMG, if I reopen the window again then every thing look OK, no overlapping of text and other controls.
Please help to understand the issue, or any suggestion to fix.

Text Editing with NSCollectionView

I've been banging my head against the wall (Cocoa) for about a week with this problem and wanted to get some advice if possible.
I'm trying to provide a list of NSTextFields to the user representing a list of features – letting them add additional textfields using an 'Add' button. This is part of a bigger form and the user should just be able to tab through the whole form (including the list)
I implemented the above using an NSCollectionView which pretty much worked except tabbing seemed to intermittently stop working in the NSCollectionView for reasons I can not figure out. You'll be hitting tab, cycling through normally when all of a sudden the collection view is skipped altogether, or sometimes if you're in a specific text field in the collection view hitting tab will just highlight the text but will never jump to the next field without mouse clicking outside the collection view. I was wondering if anyone had experienced this before... or has any advice for debugging something like this? I've attempted logging what the nextResponder is every time a control becomes the responder and there doesn't seem to be any pattern explaining why tabbing just stops working suddenly and then begins again.
There are 3 TabViews with a collection view in each. I have been wondering if that may be causing an issue?
Thanks for any help anyone can provide.
OK, after all this time I may have solved this (Tentatively anyway... I haven't seen any problems on numerous run-throughs and it usually occurs at least once every time before)
Turning on Auto Recalculates View Loop on the Main Window seems to have resolved whatever was happening. I have to admit I don't completely understand why, except that maybe because of the tab views and collections views the key loop needs to be recalculated to keep everything in sync. I'm thinking I need to do more research into exactly how the key loops work...

UTextView autocomplete vs live suggestions iOS

If I turn the autocorrection ON, the words get autocompleted, as if I write "wor", I get "word" before I finish writing. I don't want this to happen because I might be writing "world" or any word different than the autocompleted one.
I set Correction off in the Interface Builder and this problem is solved.
The problem now is that I still need the suggestions that appear in a little popover below the incomplete words.
This two features might be different but I don't know how to activate the suggestions.
How can I solve this?
This can be solved with the use of tableview. Create a tableview with the width as of the width of the textfield and height as you like. Place it just below the textfield. Make it hidden initially. When the user starts typing, fetch the array of data that resembles to the typed text and if any exists then, unhide the table view. On the subsequent typing keep on reloading the tableview sections with animations. You should be accurate on hiding, unhiding and then reloading the data on the tableview. I have implemented such thing before. It is really easy and once you get started with it you find it easy.
In the UITextView TextViewDidChange I created a thread that changed the cursor position. This, off course happens after the text view changes. The change of the cursor position triggers the autocomplete without letting me even see that there had been a suggestion.

Extended NSTableView

I would like to make a table-view with expanding ability.
When you press a row, the row should expand to show options like delete, copy and so on.
I have found an example for iOS, but I didn't get it running on Mac OS X, because NSTableView and UITableView are very different.
http://www.cocoacontrols.com/platforms/ios/controls/kofiles
Has anyone another template?
Or maybe even get this example running on Mac OS X?
I don't have code to hand you but you can use a view-based NSTableView. Your prototype view can resize itself to include controls if it's selected. All that's a bit complex to condense into a reasonably brief answer but if you use a view-based table view and treat the prototype view like any other that would grow and show extra controls, then wire this behavior to the selection state, it should work.
Note: you will have to write some code for the expansion portion, to handle resizing it, showing the controls, and notifying the table view that one of its rows changed height. Lots of documentation and examples exist out there for each individual component of your problem. Post more specific questions as you run into roadblocks.