Skip to content

Instantly share code, notes, and snippets.

@felipeslongo
Created March 21, 2019 22:58
Show Gist options
  • Save felipeslongo/6ab74e93329dc0bc05a04f39571f16fa to your computer and use it in GitHub Desktop.
Save felipeslongo/6ab74e93329dc0bc05a04f39571f16fa to your computer and use it in GitHub Desktop.
Xamarin.IOS extension that scroll to a UITableViewCell and select it (it trigger the selected events)
using System;
using System.Threading.Tasks;
using Foundation;
namespace UIKit
{
public static class UITableView_ScrollToAndSelectRow
{
private static TimeSpan CabalisticDelay => TimeSpan.FromSeconds(1);
public static void ScrollToAndSelectRow(this UITableView @this, NSIndexPath index)
=> ScrollToAndSelectRowAsync(@this, index);
private static async Task ScrollToAndSelectRowAsync(UITableView @this, NSIndexPath index)
{
//tableView.ScrollToRow(indexPath, UITableViewScrollPosition.Middle, true);
@this.SelectRow(index, true, UITableViewScrollPosition.Middle);
await Task.Delay(CabalisticDelay);
@this.Delegate.RowSelected(@this, index);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment