Last active
August 29, 2015 14:15
-
-
Save nirinchev/d9db62291e2d0812d995 to your computer and use it in GitHub Desktop.
An extension method to dequeue a cell for use in UITableViewController.GetCell
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
| public static T DequeueReusableCell<T> (this UITableView tableView) where T : UITableViewCell | |
| { | |
| var identifier = typeof(T).Name; | |
| var cell = tableView.DequeueReusableCell (identifier); | |
| if (cell == null) | |
| { | |
| // Nib with the class name MUST exist in the name bundle | |
| var nib = UINib.FromName (identifier, NSBundle.MainBundle); | |
| tableView.RegisterNibForCellReuse (nib, identifier); | |
| cell = tableView.DequeueReusableCell (identifier); | |
| } | |
| return (T)cell; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment