Created
March 21, 2019 22:58
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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