Position of UITableViewCell - objective-c

I'm using a tableview to display a list of rows and when selected, I want additional controls to appear right below the cell, probably in another view which I will control.
So far, I've managed to get a reference to the selected cell by running through the visiblecells array in the tableview but the frame property always returns a y-coordinate of 0 no matter what scroll position the table is in.
How do I get the position of the cell relative to the window?

I think the best way to deal with table views is in their own terms. That is, if you want to position something new inside the table, put it in a cell. It sounds like you want to subclass UITableViewCell to make your controls, and go through the whole tableView beginUpdates - insertCells - endUpdates process to animate their appearance.

Related

Expansion for a view-based NSTableView

I have a view-based NSTableView for which some cells have enough content that it doesn't fit. I would like to be able to have the cell automatically expand when a user hovers their cursor over the cell.
In searching for this, it seems that this is the default behavior for a cell-based NSTableView. There are even methods like shouldShowCellExpansionForTableColumn, which the doc says is for cell-based table views only. Somewhere else in the doc implies that this expansion behavior is even on by default for cell-based table views?
- (BOOL)tableView:(NSTableView *)tableView shouldShowCellExpansionForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
I get the impression that I'm missing something obvious.
Goal:
Be able to put multiple rows of NSTextField objects in a view-based cell (more than there is pace to handle)
If the content overflows, put a visual indicator into the cell
When the user does a tool-tip style hover on the cell, expand the view to show all the content
You seem to be on the right track as this should work for cell based NSTableViews. You need to put tableView:shouldShowCellExpansionForTableColumn:row: in the tableView's delegate. You could reply YES for the column of interest.
With a view based table where you use NSTextFields these scroll, truncate or wrap but there is not an expand on hover option. It is possible to set the tooltip text to be the same as the content which might be a reasonable solution.
Did you try to change the row height (tableView:heightOfRow:) triggered by some mouse action? You might have to reload the tableview.

scroll last Cell to top of UITableView

on my last cell is a dynamic textview. With bigger contentSize it will be stay on top of the tableview (to see it, while you fill it on keyboard), but if the textview and also the cell is going to be dynamically bigger: [tableview beginupdates] and [tableview endUpdates] will delete my contentSize. And after that it is scrolling it down to bottom of tableview.
Any ideas how to scroll the cell to the top, and create the cell also dynamically without changes on contentSize? maybe I'm thinking on the right way, ideas?
EDIT
Hmm..not any "correct" solution found...the best way for this purpose is to try set any new cells or sections below the textview to get this cell easy to top of the view. After this its easy to use it with beginUpdates and endUpdates. The cursor will be always in the textview, textview will be dynamically bigger also the cell, so the only easy way.
Another option is to set the uitableview as a subview of another scrollview (uitableview himself has one) to scroll up an down in the new scrollview.
Thanks for help.
From my experience, Text views in cells is a very tricky issue. I recommend just using the free Sensible TableView framework, which has text view cells available out of the box.

Custom UITableViewRowAnimation or duration

I have an app where the user can drag UITableViewCells from one TableView to another. I do this by rendering a "dummy" cell on top of the UITableViewCell that the user touches, and disable the "real" cell. I then insert a new row in the destination UITableView, after I have animated the dummy cell, to the position where the new cell will be inserted. This works as i want it to. But the other way around, causes me a lot of issues.
When a cell from the destination UITableView I double tapped, the cell should animate back to the source UITableView where it initially was dragged from. The problem is that I cannot remove the cell from the destination UITableView fast enough.
I want it to disappear instantly, so that when I render a dummy cell on top of it, I won't see an 2 different animations of the same cell. (the one where the dummy cell moves to the source UITableView, and the one where the actual cell is removed from the destination UITableView).
A reloadData on the UITableView is not good enough, because I still want the remaining cells to pull together on the now empty space, with an animation.
So, can I somehow create a custom animation, or set the duration of UITableViewRowAnimation to zero? UITableViewRowAnimationNone does not do anything for me.
Oh, and it might be important to mention that the app is not going on App Store, so I don't care if iI have to do something that Apple will not approve of.

self.title only works in viewDidLoad?

When I use self.title in any other place except viewDidLoad, nothing happens. I am trying to change the text of the navigation bar on my UIView.
I am trying to get the text off of a table cell when selected, and then make the title of the UITableView (which will show right after I touch the table cell) the text of the table cell. What is the easiest way to do this?
UINavigationItem's title inherits the value from the associated UIViewController's title, but it does this by copying the value at the time that it needs it. Once your navigation item has been added to a UINavigationBar, in order to change what it displays you need to modify the item itself, e.g. by assigning to self.navigationItem.title.

Scrolling in NSTableView

I'm not asking how to do this, it's more in line of "What would you call this?".
I have an NSTableView with several custom cells. I want the table to scroll row by row, meaning that when I move the scrollbar up I want the top row to disappear and when I move it down I want the bottom row also to disappear - I don't want to see half my cell.
How do you call this type of behavior? And can you share some pointers if you've implemented it in a NSTableView?
I'm not exactly sure what this would be called (maybe something like "constrained scrolling"?), but you can do it using NSView's -adjustScroll: method.
The general approach is that you need to make a subclass of NSTableView (if you don't already have one), and override this method to return a NSRect that has its origin.y value constrained to a multiple of your row height.
You probably also want to use NSScrollView's -setVerticalLineScroll: to set the proper amount to scroll when the user clicks the scroll arrows in the vertical scroll bar. You can get the scrollView by calling -enclosingScrollView on your tableView.