Created
March 22, 2019 21:24
-
-
Save felipeslongo/82cf162f8382b54c499a713996c5b34a to your computer and use it in GitHub Desktop.
Xamarin.IOS extension that gets the parent UITableView from the UITableViewCell
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
namespace UIKit | |
{ | |
/// <summary> | |
/// Xamarin.IOS extension that gets the parent <see cref="UITableView"/> from the <see cref="UITableViewCell"/> | |
/// </summary> | |
/// <seealso cref="https://stackoverflow.com/questions/15711645/how-to-get-uitableview-from-uitableviewcell"/> | |
public static class UITableViewCell_GetTableView | |
{ | |
/// <summary> | |
/// Gets the parent <see cref="UITableView"/> | |
/// </summary> | |
/// <param name="this"></param> | |
/// <returns><see cref="UITableView"/> instance or null ir detached</returns> | |
public static UITableView GetTableView(this UITableViewCell @this) | |
{ | |
var superView = @this.Superview; | |
while (superView != null && !(superView is UITableView)) | |
superView = superView.Superview; | |
return (UITableView)superView; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment