iOS Guides | Samples

MonoTouch.UIKit.UITableViewCell Class

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

See Also: UITableViewCell

Syntax

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

Remarks

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

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

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

A UITableViewCell may combine its UITableViewCell.ContentView with a UIView assigned to its UITableViewCell.AccessoryView property. Accessory views are often used with standard UITableViewCellAccessorys, such as a checkmark or disclosure indicator. When being edited, a 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 UITableViewCells, application developers can either customize the views used by one of the predefined styles or can subclass 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,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 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 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 UITableView.

Related content

Requirements

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

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

See Also: UIView

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.
Initializes the UITableViewCell with the specified frame.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.
Create a table cell with the given style and reuse identifier.
Create a table cell with the given style and reuse identifier.

Public Properties

AccessoryUITableViewCellAccessory. The type of standard accessory the cell should use (in its normal state).
AccessoryViewUIView. A view on the right side of a UITableViewCell (normal state).
[read-only]
static
AppearanceUITableViewCell+UITableViewCellAppearance. Strongly-typed property that returns the UIAppearance class for this class.
BackgroundViewUIView. The UIView displayed in the background of this UITableViewCell.
[read-only]
override
ClassHandleIntPtr. The handle for this class.
[read-only]
ContentViewUIView. Returns the content view of the cell object (read-only).
[read-only]
DetailTextLabelUILabel. Returns the secondary label of the table cell (read-only).
EditingBoolean. Whether the cell is in an editable state.
EditingAccessoryUITableViewCellAccessory. The type of standard accessory the cell should use (in its editing state).
EditingAccessoryViewUIView. A view on the right side of a UITableViewCell (editing state).
[read-only]
EditingStyleUITableViewCellEditingStyle. The editing style of the cell (read-only). Returns whether the cell is in an editable state, and if so whether it is showing an insertion or deletion control.
FocusStyleUITableViewCellFocusStyle. Gets or sets the focus style.
HighlightedBoolean. Whether the cell is highlighted.
[read-only]
ImageViewUIImageView. Returns the image view of the table cell (read-only).
IndentationLevelInt32. Sets the indentation level of a cell, shifting the position of the cell's content.
IndentationWidthSingle. The width of each the indentation level.
MultipleSelectionBackgroundViewUIView. The background view used when a cell is selected inside a table view that allows multiple selection.
[read-only]
ReuseIdentifierString. A string that identifies a cell object so that it can be reused.
SelectedBoolean. Whether the cell is selected.
SelectedBackgroundViewUIView. The view that is used as the cell's background when it is selected.
SelectionStyleUITableViewCellSelectionStyle. The selection style for a cell.
SeparatorInsetUIEdgeInsets. How the separator between cells should be inset.
ShouldIndentWhileEditingBoolean. Whether the cell background is indented while in editing mode.
ShowingDeleteConfirmationBoolean. Whether the delete confirmation button is currently showing in the cell (read-only).
ShowsReorderControlBoolean. Whether the reordering control is currently showing in the cell (read-only).
[read-only]
TextLabelUILabel. Returns the label that displays the main text content in the cell (read-only).

Public Methods

static
AppearanceWhenContainedIn(params Type[]) : UITableViewCell+UITableViewCellAppearance
Returns a strongly typed UIAppearance for instances of this class when the view is hosted in the specified hierarchy.
DidTransitionToState(UITableViewCellState)
Called on the cell just after it transitions between cell states.
static
GetAppearance(UITraitCollection) : UITableViewCell+UITableViewCellAppearance
Returns an appearance proxy for the specified traits.
static
GetAppearance(UITraitCollection, params Type[]) : UITableViewCell+UITableViewCellAppearance
Returns an appearance proxy for the specified traits when found in the containers containment hierarchy.
static
GetAppearance<T>() : UITableViewCell+UITableViewCellAppearance
Obtains the appearance proxy UITableViewCellAppearance for the subclass of UITableViewCell.
static
GetAppearance<T>(UITraitCollection) : UITableViewCell+UITableViewCellAppearance
Obtains the appearance proxy UITableViewCellAppearance for the subclass of UITableViewCell.
static
GetAppearance<T>(UITraitCollection, params Type[]) : UITableViewCell+UITableViewCellAppearance
Obtains the appearance proxy UITableViewCellAppearance for the subclass of UITableViewCell that has the specified trait collection when the view is hosted in the specified hierarchy.
PrepareForReuse()
Prepares a cell for reuse by the table view's UITableViewSource.
SetEditing(Boolean, Boolean)
Toggles the cell in and out of editing mode.
SetHighlighted(Boolean, Boolean)
Sets the highlighted state of the cell, optionally animating the transition between states.
SetSelected(Boolean, Boolean)
Sets the selected state of the cell, optionally animating the transition between the states.
ShouldBegin(UIGestureRecognizer) : Boolean
Whether the gesture recognition should begin.
ShouldBeRequiredToFailBy(UIGestureRecognizer, UIGestureRecognizer) : Boolean
Whether there is a dynamic failure requirement between the specified gesture recognizers.
ShouldReceivePress(UIGestureRecognizer, UIPress) : Boolean
ShouldReceiveTouch(UIGestureRecognizer, UITouch) : Boolean
Whether the recognizer should receive the specified touch.
ShouldRecognizeSimultaneously(UIGestureRecognizer, UIGestureRecognizer) : Boolean
Whether the two gesture recognizers should be allowed to recognize gestures simultaneously.
ShouldRequireFailureOf(UIGestureRecognizer, UIGestureRecognizer) : Boolean
Whether the specified gestureRecognizer should be required to fail by the otherGestureRecognizer.
WillTransitionToState(UITableViewCellState)
Called on the cell just before it transitions between states.