In my iOS customer renderer for a ListView I set a boolean _scrollToBottom to true and then it gets updated here. (Maybe this is the wrong place to do this?)
But if I want to animate the bottom of the table is always slightly wrong by like 20 pixels or so. If I Wait 100ms like shown it works perfect. What's the proper way to do this without the 100ms wait?
public class MyListViewRenderer : ViewRenderer<MyListView, UITableView>
public override void LayoutSubviews()
{
base.LayoutSubviews();
Task.Run(() =>
{
if (_scrollToBottom)
{
Task.Delay(100).Wait();
Device.BeginInvokeOnMainThread(() =>
{
var tableView = Control;
// Scroll to bottom
if (tableView.ContentSize.Height > tableView.Frame.Height)
{
var rowCount = tableView.NumberOfRowsInSection(0);
if (rowCount > 0)
{
tableView.ScrollToRow(MonoTouch.Foundation.NSIndexPath.FromRowSection(rowCount - 1, 0),
UITableViewScrollPosition.Bottom, true);
}
}
_scrollToBottom = false;
});
});
}
}