iOS Guides | Samples

MonoTouch.UIKit.UITableViewDataSource Class

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

See Also: UITableViewDataSource

Syntax

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

See Also

Remarks

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

The 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 UITableViewDataSource is to provide individual UITableViewCells in response to calls to UITableViewDataSource.GetCell. That call takes as arguments the UITableView in question and an NSIndexPath. That 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 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 UITableViewCells from calls to UITableViewDataSource.GetCell. Dynamic tables should use the 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 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 UITableViewCell as necessary.

Related content

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.UIKit.UITableViewDataSource are listed below.

See Also: NSObject

Public Constructors

Default constructor that initializes a new instance of this class with no parameters.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Methods

CanEditRow(UITableView, NSIndexPath) : Boolean
Whether the row located at indexPath should be editable.
CanMoveRow(UITableView, NSIndexPath) : Boolean
Whether the row located at indexPath can be moved to another location in the table view.
CommitEditingStyle(UITableView, UITableViewCellEditingStyle, NSIndexPath)
Commits the insertion or deletion of the specified row.
abstract
GetCell(UITableView, NSIndexPath) : UITableViewCell
Called by the table view to get populate the row at indexPath with a cell view.
MoveRow(UITableView, NSIndexPath, NSIndexPath)
Called when a row has been moved so that the data source can 'implement' the changed row position that has been performed in the user interface. This ensures the data is kept in-sync with what is being displayed.
NumberOfSections(UITableView) : Int32
Returns the number of sections that are required to display the data.
abstract
RowsInSection(UITableView, Int32) : Int32
Called by the table view to find out how many rows are to be rendered in the section specified by section.
SectionFor(UITableView, String, Int32) : Int32
Returns the index of the section with the given tableView and atIndex.
SectionIndexTitles(UITableView) : String[]
Returns an array of titles to be displayed as an index on the table view.
TitleForFooter(UITableView, Int32) : String
Called to populate the footer for the specified section.
TitleForHeader(UITableView, Int32) : String
Called to populate the header for the specified section.