Make the UITableView "sticky to the bottom"

Let's say you have a tabular view T that shows messages,

T[ message d
T[ message c
T[ message b
T[ most recent message down bottom

      

Let's say there are 100 messages and at the bottom 4 are seen in the example.

So the table height is 700. You have a typical text entry at the bottom ...

T[ message d
T[ message c
T[ message b
T[ most recent message down bottom
[enter snapped chat message!] [send]

      

When the keyboard appears, the new height of the visible table view is 400.

Of course, this will "cut off the bottom" of the messages - the last two will no longer be visible.

T[ message d
T[ message c
[enter snapped chat message!] [send]
[           iOS keyboard        ]
[           iOS keyboard        ]

      

(So ​​messages A and B are now under the keyboard.)

Naturally what you do is just scroll through the table after the keyboard appears, for example. Doing it in a slow manner without any problems.

However, it would be really natural if you could subclass the UITableView so that when the viewable area is resized, the view in the table knows that the "bottom point" is identical .

So, as the bottom of the table moves up and down (due to a keyboard or whatever), the table will actually scroll based on the movement of the table's "base".

(Among other things, this would solve "animation timing match").

Could this be achieved gracefully, and if so, how does it really seem so natural these days, perhaps it's embedded in the UITableView as a flag and I just don't know?

again the question is here

How do I change the UITableView so that it moves its own scroll position as the view resizes ...

(to keep the "bottom point the same")

Note that it is trivial to simply scroll the table "by hand" as it was outside.

+3


source to share


2 answers


The section headers stick to the top, so something like this might be:
1. Make the last post as a section header instead of a table cell
2. Mirror the table vertically:
tableView.transform = CGAffineTransformMakeScale(1, -1);


3. Mirror vertically split the table header and table cells
4. Reorder your messages.



Is this what you were looking for?

+2


source


As far as I know, you have several options for this:

If you have the indexPath of the line you want to see:

tableView.ScrollToRow(indexPath, UITableViewScrollPosition.Top, true);

      



This will scroll to the cell specified by indexPath. In this case, you choose an option to display it on the .Top

screen.

If you don't have indexPath, you can use:

tableView.ScrollRectToVisible(new RectangleF(0, Ydisplacement, tableView.Width, tableView.Height), true);

      

0


source







All Articles