UIKit.UITableViewCell Class
A UIKit.UIView that displays an element displayed by the UIKit.UITableView. Cells can be reused.

See Also: UITableViewCell Members

Syntax

[Foundation.Register("UITableViewCell", true)]
public class UITableViewCell : UIView

Remarks

A UIKit.UITableViewCell represents a single cell (row) in a UIKit.UITableView. UIKit.UITableViewCells are typically allocated in the UITableViewSource.GetCell method of UIKit.UITableViewSource if UITableView.DequeueReusableCell returns null. (See discussion at UIKit.UITableView or UITableViewSource.GetCell).

There are four predefined UIKit.UITableViewCell styles, which can be created by using the UITableViewCell(UITableViewCellStyle, NSString) constructor. These predefined styles appear as follows:

All of the predefined styles have UITableViewCell.TextLabel and UITableViewCell.DetailTextLabel properties of type UIKit.UILabel and all but UITableViewCellStyle.Value2 have a UITableViewCell.Image of type UIKit.UIImage. Assignment to the UITableViewCell.Image property of a cell initialized with the UITableViewCellStyle.Value2 style will result in a runtime exception.

A UIKit.UITableViewCell may combine its UITableViewCell.ContentView with a UIKit.UIView assigned to its UITableViewCell.AccessoryView property. Accessory views are often used with standard UIKit.UITableViewCellAccessorys, such as a checkmark or disclosure indicator. When being edited, a UIKit.UITableViewCell will combine its UITableViewCell.ContentView with an editing control on the left and, optionally, a reordering control on the right.

In a non-selected cell, the UITableViewCell.BackgroundView is displayed, while a selected cell will show its UITableViewCell.SelectedBackgroundView view.

To customize UIKit.UITableViewCells, application developers can either customize the views used by one of the predefined styles or can subclass UIKit.UITableViewCell. (In addition, application developers will often override UITableViewSource.GetHeightForRow.)

Starting with iOS 8, table view cells can be auto-sized, and no longer require the UITableViewSource.GetHeightForRow(UITableView, Foundation.NSIndexPath) to be implemented to size cells. To do this, the cell constructor should set the UITableViewCell.ContentView constraints.

Note:

Application developers should prefer subclassing UIKit.UITableViewCell over extensive customization of predefined styles. Xamarin's experience is that subclassing is less error-prone. Although subclassing introduces the normal overhead of a new class, this is generally a minor trade-off in comparison to the importance and complexity of the customized cell.

Because UIKit.UITableViewCells appear rapidly during scrolling, application developers should avoid layout recalculations and higher-cost rendering techniques such as the use of transparent views.

Application developers should make a strong effort to reuse cells with the UITableView.DequeueReusableCell method of UIKit.UITableView.

Related content

Requirements

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