UIKit.UITableViewDataSource Class
The data source for a UIKit.UITableView. Xamarin.iOS developers should prefer to use UIKit.UITableViewSource instead of this class.

See Also: UITableViewDataSource Members

Syntax

[Foundation.Model]
[Foundation.Protocol]
[Foundation.Register("UITableViewDataSource", false)]
public abstract class UITableViewDataSource : Foundation.NSObject, IUITableViewDataSource, IDisposable

See Also

UITableView
UITableViewSource
UITableViewCell
UITableViewDelegate

Remarks

Implementing UIKit.UITableView often requires subclasses of both UIKit.UITableViewDataSource and UIKit.UITableViewDelegate to provide data and behavior for the table view. Xamarin.iOS provides a single class - UIKit.UITableViewSource - so that only one class needs to be implemented.

The UIKit.UITableViewDataSource class methods provide a table view with all the information it requires to display its data - such as informing it of the number of sections and rows, and what cell view to use for each row.

The universally-important function of UIKit.UITableViewDataSource is to provide individual UIKit.UITableViewCells in response to calls to UITableViewDataSource.GetCell. That call takes as arguments the UIKit.UITableView in question and an Foundation.NSIndexPath. That Foundation.NSIndexPath is based, in turn, on calls to UITableViewDataSource.NumberOfSections and UITableViewDataSource.RowsInSection, so the application developer must, at a minimum, override these three functions. (The UIKit.UITableView additionally calls UITableViewDelegate.GetHeightForRow and other layout-related methods for header and footer views and the application developer must override these as appropriate.)

Static tables may return references to pre-allocated UIKit.UITableViewCells from calls to UITableViewDataSource.GetCell. Dynamic tables should use the UIKit.UITableView's built-in cell reuse cache by calling UITableView.DequeueReusableCell. In iOS 6 and later, application developers should use UITableView.RegisterClassForCellReuse or UITableView.RegisterNibForCellReuse during initialization, in which case UITableView.DequeueReusableCell will instantiate new UIKit.UITableViewCells as necessary. If application developers are targeting earlier iOS versions, their override of UITableViewDataSource.GetCell must check for an null return from UITableView.DequeueReusableCell and instantiate a UIKit.UITableViewCell as necessary.

Related content

Requirements

Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0