Have an NSTableView row always stay in the same place - cocoa

Im trying to make a trash can system in my app. I have a NSTableView and a trash can row. I want to have the row "stick" to the bottom of the visible table view so it can always be seen. Is it possible to do this and if not is there a better approach to doing this?
Thanks for any help

Sit another utterly separate UIView, on top the views that contain the table.
Simply fake it up to make it look like a row from the table.
As you say, "Thanks that sounds like it will work as long [tableview deselectRow:[tableview selectedRow] works so it appears that the fake row is really in the view." -- that is precisely what you do.

There's no supported way to do this and it might be near impossible. You might try embedding your "main" table view in a container NSView (that observes the table view's frame changes resizes / performs layout when the size changes). This view would leave room at the bottom for a single-row table view with no headers. You could feed the "main" table view all but the sticky row, and feed only the sticky row to the smaller table.

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.

Cells don't resize when user resizes NSTableViews columns?

I have found that the text in a table view doesn't grow when the user resizes the column. (Or for that matter shrink if he shrinks the column, because the truncation ellipses then vanish.) Having gathered that this is something to do with constraints, my solution has been to uncheck Use Auto Layout (in the xib's file inspector). Not a big deal, but it comes just when I was beginning to think I might have mastered Autolayout.
Is that really the only way to do this?
The table is view-based, and gets its data from Core Data via an array controller. The text is displayed in an NSTextField.
It is as you have found out yourself.
If you want to know/learn more about NSTableview-behavior search for "TableViewVariableRowHeights" and "TableViewLinks" in Apples documentation and download the samples.
This question appears to be answered in:
How to Expand NSTableCellView Width When Resizing Column in NSTableView
summary: add horizontal constraints to the table view cell
see the link for screenshots

Prototype Cells in UITableView not on top

It's really strange. The Prototype-Cell in my second UITableView isn't on top as it should be:
If I start moving it, than it's on top again, but after i drop it on my View, it is still in this strange way.
How can I change that?
As you see, the first Cell is okay, but the second isn't.
Well, it's difficult to understand using only an image, but I will give you some possible causes for that:
Have you applied a table header view by accident in the second table view? If you did, removing it will be the solution
Have you applied the proper view constraints in the table view and its cells?
If I were you, I would not try to embed two UITableViews in the same view controller this way, especially since you use storyboards with iOS 7. What I would do is to use embed segues. Just drag a container view for each of your view table views, and connect their embed segues to their appropriate table view controllers ( you need to create in the storyboard those, two). That way, you can set the constraints much easier, separate the logic between the two and have a cleaner interface. You can do that and see if that helps.

mouseOver for NSTableView

I have NSTableView in my application and i have added the hovering effect for the rows by using HoverTableDemo.
I can get the hovering effect only for one row in my table.
It is not apply for the whole table.
How can i get Hovering effect for full table.
Can any body have any idea please revert me.
Take a look: https://stackoverflow.com/a/464828/1758762
You're on the right track with -mouseEntered: and -mouseExited:.
Look into NSView's -addTrackingRect:owner:userData:assumeInside: and -removeTrackingRect: methods.
I can get the hovering effect only for one row in my table.
You can either set up your tableView to create trackingRects for every row that's in there whenever the contents of the tableView change, or alternatively, set up/update one tracking area on the entire tableView whenever -tile or another layout related method is called.

How do I reset a table view?

I have a table view in an iPhone xcode tab bar application that shows data either alphabetically or numerically, depending on a user selected option in one of the tabs. It works for the most part, but when I change the option and then go back into the table view, the table view initially looks like it did before the option was changed. However, as new cells get scrolled into view, they have the new display mode.
I can identify when the option changes, but I can't seem to get the code correct that would re-initialize the cells such that the next time they come into view they have the correct values. The data comes from a static array with set values, so I don't want to do anything with the data source, just the table view.
In other words, once the display option changes, I want to wipe out the table view I have so that the next time the table view displays it will show the correct data right from the start rather than after scrolling occurs.
Any help would be appreciated. Thanks.
It sounds like you want to call reloadData on the TableView.
[yourTableView reloadData];

Resources