iOS Developer Library

Developer

UIKit Framework Reference UITableViewCell Class Reference

Options
Deployment Target:

On This Page
Language:

UITableViewCell

The UITableViewCell class defines the attributes and behavior of the cells that appear in UITableView objects. This class includes properties and methods for setting and managing cell content and background (including text, images, and custom views), managing the cell selection and highlight state, managing accessory views, and initiating the editing of the cell contents. More...

Inheritance


Import Statement


import UIKit @import UIKit;

Availability


Available in iOS 2.0 and later.
  • Initializes a table cell with a style and a reuse identifier and returns it to the caller.

    Declaration

    Swift

    init(style style: UITableViewCellStyle, reuseIdentifier reuseIdentifier: String?)

    Objective-C

    - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

    Parameters

    style

    A constant indicating a cell style. See UITableViewCellStyle for descriptions of these constants.

    reuseIdentifier

    A string used to identify the cell object if it is to be reused for drawing multiple rows of a table view. Pass nil if the cell object is not to be reused. You should use the same reuse identifier for all cells of the same form.

    Return Value

    An initialized UITableViewCell object or nil if the object could not be created.

    Discussion

    This method is the designated initializer for the class. The reuse identifier is associated with those cells (rows) of a table view that have the same general configuration, minus cell content. In its implementation of tableView:cellForRowAtIndexPath:, the table view'€™s data source calls the UITableView method dequeueReusableCellWithIdentifier:, passing in a reuse identifier, to obtain the cell object to use as the basis for the current row.

    If you want a table cell that has a configuration different that those defined by UITableViewCell for style, you must create your own custom cell. If you want to set the row height of cells on an individual basis, implement the delegate method tableView:heightForRowAtIndexPath:.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.0 and later.

  • A string used to identify a cell that is reusable. (read-only)

    Declaration

    Swift

    var reuseIdentifier: String? { get }

    Objective-C

    @property(nonatomic, readonly, copy) NSString *reuseIdentifier

    Discussion

    The reuse identifier is associated with a UITableViewCell object that the table-view’s delegate creates with the intent to reuse it as the basis (for performance reasons) for multiple rows of a table view. It is assigned to the cell object in initWithFrame:reuseIdentifier: and cannot be changed thereafter. A UITableView object maintains a queue (or list) of the currently reusable cells, each with its own reuse identifier, and makes them available to the delegate in the dequeueReusableCellWithIdentifier: method.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Prepares a reusable cell for reuse by the table view'€™s delegate.

    Declaration

    Swift

    func prepareForReuse()

    Objective-C

    - (void)prepareForReuse

    Discussion

    If a UITableViewCell object is reusable—that is, it has a reuse identifier—this method is invoked just before the object is returned from the UITableView method dequeueReusableCellWithIdentifier:. For performance reasons, you should only reset attributes of the cell that are not related to content, for example, alpha, editing, and selection state. The table view'€™s delegate in tableView:cellForRowAtIndexPath: should always reset all content when reusing a cell. If the cell object does not have an associated reuse identifier, this method is not called. If you override this method, you must be sure to invoke the superclass implementation.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • textLabel textLabel Property

    Returns the label used for the main textual content of the table cell. (read-only)

    Declaration

    Swift

    var textLabel: UILabel? { get }

    Objective-C

    @property(nonatomic, readonly, retain) UILabel *textLabel

    Discussion

    Holds the main label of the cell. UITableViewCell adds an appropriate label when you create the cell in a given cell style. See UITableViewCellStyle for descriptions of the main label in currently defined cell styles.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.0 and later.

  • Returns the secondary label of the table cell if one exists. (read-only)

    Declaration

    Swift

    var detailTextLabel: UILabel? { get }

    Objective-C

    @property(nonatomic, readonly, retain) UILabel *detailTextLabel

    Discussion

    Holds the secondary (or detail) label of the cell. UITableViewCell adds an appropriate label when you create the cell in a style that supports secondary labels. If the style doesn’t support detail labels, nil is returned. See UITableViewCellStyle for descriptions of the main label in currently defined cell styles.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.0 and later.

  • imageView imageView Property

    Returns the image view of the table cell. (read-only)

    Declaration

    Swift

    var imageView: UIImageView? { get }

    Objective-C

    @property(nonatomic, readonly, retain) UIImageView *imageView

    Discussion

    Returns the image view (UIImageView object) of the table view, which initially has no image set. If an image is set, it appears on the left side of the cell, before any label. UITableViewCell creates the image-view object when you create the cell.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.0 and later.

  • Returns the content view of the cell object. (read-only)

    Declaration

    Swift

    var contentView: UIView { get }

    Objective-C

    @property(nonatomic, readonly, retain) UIView *contentView

    Discussion

    The content view of a UITableViewCell object is the default superview for content displayed by the cell. If you want to customize cells by simply adding additional views, you should add them to the content view so they will be positioned appropriately as the cell transitions into and out of editing mode.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

    See Also

    backgroundView

  • The view used as the background of the cell.

    Declaration

    Swift

    var backgroundView: UIView?

    Objective-C

    @property(nonatomic, retain) UIView *backgroundView

    Discussion

    The default is nil for cells in plain-style tables (UITableViewStylePlain) and non-nil for grouped-style tables UITableViewStyleGrouped). UITableViewCell adds the background view as a subview behind all other views and uses its current frame location.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The view used as the background of the cell when it is selected.

    Declaration

    Swift

    var selectedBackgroundView: UIView!

    Objective-C

    @property(nonatomic, retain) UIView *selectedBackgroundView

    Discussion

    The default is nil for cells in plain-style tables (UITableViewStylePlain) and non-nil for section-group tables UITableViewStyleGrouped). UITableViewCell adds the value of this property as a subview only when the cell is selected. It adds the selected background view as a subview directly above the background view (backgroundView) if it is not nil, or behind all other views. Calling setSelected:animated: causes the selected background view to animate in and out with an alpha fade.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The background view to use for a selected cell when the table view allows multiple row selections.

    Declaration

    Swift

    var multipleSelectionBackgroundView: UIView?

    Objective-C

    @property(nonatomic, retain) UIView *multipleSelectionBackgroundView

    Discussion

    If this property is not nil, this view is used as the background view for a selected cell when the table view allows multiple row selections. You enable multiple row selections through the allowsMultipleSelection and allowsMultipleSelectionDuringEditing properties of UITableView.

    Import Statement

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • selected selected Property

    A Boolean value that indicates whether the cell is selected.

    Declaration

    Swift

    var selected: Bool

    Objective-C

    @property(nonatomic, getter=isSelected) BOOL selected

    Discussion

    The selection affects the appearance of labels, image, and background. When the selected state of a cell is set to YEStrue, it draws the background for selected cells with its title in white. The default value is NOfalse. If you set the selection state to YEStrue through this property, the transition to the new state appearance is not animated. For animated selected-state transitions, see the setSelected:animated: method.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

    See Also

    selectionStyle

  • The style of selection for a cell.

    Declaration

    Swift

    var selectionStyle: UITableViewCellSelectionStyle

    Objective-C

    @property(nonatomic) UITableViewCellSelectionStyle selectionStyle

    Discussion

    The selection style is a backgroundView constant that determines the color of a cell when it is selected. The default value is UITableViewCellSelectionStyleBlue. See UITableViewCellSelectionStyle for a description of valid constants.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Sets the selected state of the cell, optionally animating the transition between states.

    Declaration

    Swift

    func setSelected(_ selected: Bool, animated animated: Bool)

    Objective-C

    - (void)setSelected:(BOOL)selected animated:(BOOL)animated

    Parameters

    selected

    YEStrue to set the cell as selected, NOfalse to set it as unselected. The default is NOfalse.

    animated

    YEStrue to animate the transition between selected states, NOfalse to make the transition immediate.

    Discussion

    The selection affects the appearance of labels, image, and background. When the selected state of a cell is YEStrue, it draws the background for selected cells (“Reusing Cells”) with its title in white.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • A Boolean value that indicates whether the cell is highlighted.

    Declaration

    Swift

    var highlighted: Bool

    Objective-C

    @property(nonatomic, getter=isHighlighted) BOOL highlighted

    Discussion

    The highlighting affects the appearance of labels, image, and background. When the highlighted state of a cell is set to YEStrue, labels are drawn in their highlighted text color (default is white). The default value is NOfalse. If you set the highlighted state to YEStrue through this property, the transition to the new state appearance is not animated. For animated highlighted-state transitions, see the setHighlighted:animated: method.

    Note that for highlighting to work properly, you must fetch the cell’s labels using the textLabel and detailTextLabel properties and set each label’s highlightedTextColor property; for images, get the cell’s image using the imageView property and set the UIImageView object’s highlightedImage property.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.0 and later.

  • Sets the highlighted state of the cell, optionally animating the transition between states.

    Declaration

    Swift

    func setHighlighted(_ highlighted: Bool, animated animated: Bool)

    Objective-C

    - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated

    Parameters

    highlighted

    YEStrue to set the cell as highlighted, NOfalse to set it as unhighlighted. The default is NOfalse.

    animated

    YEStrue to animate the transition between highlighted states, NOfalse to make the transition immediate.

    Discussion

    Highlights or unhighlights the cell, animating the transition between regular and highlighted state if animated is YES. Highlighting affects the appearance of the cell’s labels, image, and background.

    Note that for highlighting to work properly, you must fetch the cell’s label (or labels) using the textLabel (and detailTextLabel properties and set the label’s highlightedTextColor property; for images, get the cell’s image using the imageView property and set the UIImageView object’s highlightedImage property.

    A custom table cell may override this method to make any transitory appearance changes.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.0 and later.

  • editing editing Property

    A Boolean value that indicates whether the cell is in an editable state.

    Declaration

    Swift

    var editing: Bool

    Objective-C

    @property(nonatomic, getter=isEditing) BOOL editing

    Discussion

    When a cell is in an editable state, it displays the editing controls specified for it: the green insertion control, the red deletion control, or (on the right side) the reordering control. Use editingStyle and showsReorderControl to specify these controls for the cell.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Toggles the receiver into and out of editing mode.

    Declaration

    Swift

    func setEditing(_ editing: Bool, animated animated: Bool)

    Objective-C

    - (void)setEditing:(BOOL)editing animated:(BOOL)animated

    Parameters

    editing

    YEStrue to enter editing mode, NOfalse to leave it. The default value is NOfalse .

    animated

    YEStrue to animate the appearance or disappearance of the insertion/deletion control and the reordering control, NOfalse to make the transition immediate.

    Discussion

    When you call this method with the value of editing set to YEStrue, and the UITableViewCell object is configured to have controls, the cell shows an insertion (green plus) or deletion control (red minus) on the left side of each cell and a reordering control on the right side. This method is called on each visible cell when the setEditing:animated: method of UITableView is invoked. Calling this method with editing set to NOfalse removes the controls from the cell.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

    See Also

    editing

  • The editing style of the cell. (read-only)

    Declaration

    Swift

    var editingStyle: UITableViewCellEditingStyle { get }

    Objective-C

    @property(nonatomic, readonly) UITableViewCellEditingStyle editingStyle

    Discussion

    One of the constants described in “UITableViewCellEditingStyle” is used as the value of this property; it specifies whether the cell is in an editable state and, if it is, whether it shows an insertion or deletion control. The default value is UITableViewCellEditingStyleNone (not editable). The delegate returns the value of this property for a particular cell in its implementation of the tableView:editingStyleForRowAtIndexPath: method.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

    See Also

    editing

  • Returns whether the cell is currently showing the delete-confirmation button. (read-only)

    Declaration

    Swift

    var showingDeleteConfirmation: Bool { get }

    Objective-C

    @property(nonatomic, readonly) BOOL showingDeleteConfirmation

    Discussion

    When users tap the deletion control (the red circle to the left of the cell), the cell displays a "Delete" button on the right side of the cell; this string is localized.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • A Boolean value that determines whether the cell shows the reordering control.

    Declaration

    Swift

    var showsReorderControl: Bool

    Objective-C

    @property(nonatomic) BOOL showsReorderControl

    Discussion

    The reordering control is gray, multiple horizontal bar control on the right side of the cell. Users can drag this control to reorder the cell within the table. The default value is NOfalse. If the value is YEStrue , the reordering control temporarily replaces any accessory view.

    For the reordering control to appear, you must not only set this property but implement the UITableViewDataSource method tableView:moveRowAtIndexPath:toIndexPath:. In addition, if the data source implements tableView:canMoveRowAtIndexPath: to return NOfalse, the reordering control does not appear in that designated row.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The indentation level of the cell’s content.

    Declaration

    Swift

    var indentationLevel: Int

    Objective-C

    @property(nonatomic) NSInteger indentationLevel

    Discussion

    The default value of the property is zero (no indentation). Assigning a positive value to this property indents the cell’s content from the left edge of the cell separator. The amount of indentation is equal to the indentation level multiplied by the value in the indentationWidth property.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The width for each level of indentation of a cell'€™s content.

    Declaration

    Swift

    var indentationWidth: CGFloat

    Objective-C

    @property(nonatomic) CGFloat indentationWidth

    Discussion

    The default indentation width is 10.0 points.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

    See Also

    indentationLevel

  • A Boolean value that controls whether the cell background is indented when the table view is in editing mode.

    Declaration

    Swift

    var shouldIndentWhileEditing: Bool

    Objective-C

    @property(nonatomic) BOOL shouldIndentWhileEditing

    Discussion

    The default value is YEStrue. This property is unrelated to indentationLevel. The delegate can override this value in tableView:shouldIndentWhileEditingRowAtIndexPath:. This property has an effect only on table views created in the grouped style (UITableViewStyleGrouped); it has no effect on UITableViewStylePlain table views.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The inset values for the cell’s content.

    Declaration

    Swift

    var separatorInset: UIEdgeInsets

    Objective-C

    @property(nonatomic) UIEdgeInsets separatorInset

    Discussion

    You can use this property to add space between the current cell’s contents and the left and right edges of the table. Positive inset values move the cell content and cell separator inward and away from the table edges. Negative values are treated as if the inset is set to 0.

    Only the left and right inset values are respected; the top and bottom inset values are ignored. The value assigned to this property takes precedence over any default separator insets set on the table view.

    Import Statement

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Initializes and returns a table cell object.

    Deprecation Statement

    Use initWithStyle:reuseIdentifier: instead.

    Declaration

    Objective-C

    - (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier

    Parameters

    frame

    The frame rectangle of the cell. Because the table view automatically positions the cell and makes it the optimal size, you can pass in CGRectZero in most cases. However, if you have a custom cell with multiple subviews, each with its own autoresizing mask, you must specify a non-zero frame rectangle; this allows the table view to position the subviews automatically as the cell changes size.

    reuseIdentifier

    A string used to identify the cell object if it is to be reused for drawing multiple rows of a table view. Pass nil if the cell object is not to be reused.

    Return Value

    An initialized UITableViewCell object or nil if the object could not be created.

    Discussion

    This method is the designated initializer for the class. The reuse identifier is associated with those cells (rows) of a table view that have the same general configuration, minus cell content. In its implementation of tableView:cellForRowAtIndexPath:, the table view's delegate calls the UITableView method dequeueReusableCellWithIdentifier:, passing in a reuse identifier, to obtain the cell object to use as the basis for the current row.

    Import Statement

    Availability

    Available in iOS 2.0 and later.

    Deprecated in iOS 3.0.

    See Also

    reuseIdentifier

  • text text (iOS 3.0) Property

    The text of the cell.

    Deprecation Statement

    Use the textLabel and detailTextLabel properties instead.

    Declaration

    Objective-C

    @property(nonatomic, copy) NSString *text

    Discussion

    The default is nil (no text).

    Import Statement

    Availability

    Available in iOS 2.0 and later.

    Deprecated in iOS 3.0.

  • font font (iOS 3.0) Property

    The font of the title.

    Deprecation Statement

    Instead, set the fonts of the UILabel objects assigned to the textLabel and detailTextLabel properties.

    Declaration

    Objective-C

    @property(nonatomic, retain) UIFont *font

    Discussion

    If the value of this property is nil (the default), UITableViewCell uses a standard font optimized for the device.

    Import Statement

    Availability

    Available in iOS 2.0 and later.

    Deprecated in iOS 3.0.

  • textAlignment textAlignment (iOS 3.0) Property

    A constant that specifies the alignment of text in the cell.

    Deprecation Statement

    Instead set the text alignment of the UILabel objects assigned to the textLabel and detailTextLabel properties.

    Declaration

    Objective-C

    @property(nonatomic) NSTextAlignment textAlignment

    Discussion

    If the value of the property is nil (the default), the title is left-aligned (UITextAlignmentLeft). See the descriptions of the UITextAlignment constants for alternative text alignments.

    Import Statement

    Availability

    Available in iOS 2.0 and later.

    Deprecated in iOS 3.0.

  • textColor textColor (iOS 3.0) Property

    The color of the title text.

    Deprecation Statement

    Instead set the text color attribute of the UILabel objects assigned to the textLabel and detailTextLabel properties.

    Declaration

    Objective-C

    @property(nonatomic, retain) UIColor *textColor

    Discussion

    If the value of property is nil (the default), the color of text is black.

    Import Statement

    Availability

    Available in iOS 2.0 and later.

    Deprecated in iOS 3.0.

  • The color of the title text when the cell is selected.

    Deprecation Statement

    Instead set the highlightedTextColor property of the UILabel objects assigned to the textLabel and detailTextLabel properties.

    Declaration

    Objective-C

    @property(nonatomic, retain) UIColor *selectedTextColor

    Discussion

    If the value of property is nil (the default), the color of text in a selected cell is white.

    Import Statement

    Availability

    Available in iOS 2.0 and later.

    Deprecated in iOS 3.0.

  • lineBreakMode lineBreakMode (iOS 3.0) Property

    The mode for for wrapping and truncating text in the cell.

    Deprecation Statement

    Instead set the line-break mode attribute of the UILabel objects assigned to the textLabel and detailTextLabel properties.

    Declaration

    Objective-C

    @property(nonatomic) NSLineBreakMode lineBreakMode

    Discussion

    For further information, see the UILineBreakMode constants described in NSString UIKit Additions Reference. The default value is UILineBreakModeTailTruncation.

    Import Statement

    Availability

    Available in iOS 2.0 and later.

    Deprecated in iOS 3.0.

  • image image (iOS 3.0) Property

    The image to use as content for the cell.

    Deprecation Statement

    Instead use the imageView property to get UIImageView object and then get or set the encapsulated image.

    Declaration

    Objective-C

    @property(nonatomic, retain) UIImage *image

    Discussion

    The default value of the property is nil (no image). Images are positioned to the left of the title.

    Import Statement

    Availability

    Available in iOS 2.0 and later.

    Deprecated in iOS 3.0.

    See Also

    selectedImage

  • selectedImage selectedImage (iOS 3.0) Property

    The image to use a cell content when the cell is selected.

    Deprecation Statement

    Instead use the imageView property to obtain the UIImageView object and then get or set its highlightedImage property.

    Declaration

    Objective-C

    @property(nonatomic, retain) UIImage *selectedImage

    Discussion

    The default value of this property is nil (no image).

    Import Statement

    Availability

    Available in iOS 2.0 and later.

    Deprecated in iOS 3.0.

    See Also

    image

  • A Boolean value that determines whether the accessory view is hidden when the cell is being edited.

    Deprecation Statement

    Use the editingAccessoryType and editingAccessoryView properties instead.

    Declaration

    Objective-C

    @property(nonatomic) BOOL hidesAccessoryWhenEditing

    Discussion

    The default value is YEStrue.

    Import Statement

    Availability

    Available in iOS 2.0 and later.

    Deprecated in iOS 3.0.

  • target target (iOS 3.0) Property

    The target object to receive action messages.

    Deprecation Statement

    Instead use the tableView:commitEditingStyle:forRowAtIndexPath: or tableView:accessoryButtonTappedForRowWithIndexPath: for handling taps on cells.

    Declaration

    Objective-C

    @property(nonatomic, assign) id target

    Discussion

    The target object receives action messages when the user taps a cell'€™s insert button, delete button, or accessory view. The default value is nil, which tells the application to go up the responder chain to find a target. Note that the target is a weak reference.

    Import Statement

    Availability

    Available in iOS 2.0 and later.

    Deprecated in iOS 3.0.

  • editAction editAction (iOS 3.0) Property

    The selector defining the action message to invoke when users tap the insert or delete button.

    Deprecation Statement

    Instead use the tableView:commitEditingStyle:forRowAtIndexPath: or tableView:accessoryButtonTappedForRowWithIndexPath: for handling taps on cells.

    Declaration

    Objective-C

    @property(nonatomic) SEL editAction

    Discussion

    When the cell'€™s table is in editing mode, the cell displays a green insert control or a red delete control to the left of it. (The selectedBackgroundView constant applied to the cell via the editingStyle property determines which control is used.) Typically, the associated UITableView object sets the editing action for all cells; you can use this property to alter the editing action for individual cells. If the value of this property is NULL, no action message is sent.

    Import Statement

    Availability

    Available in iOS 2.0 and later.

    Deprecated in iOS 3.0.

  • accessoryAction accessoryAction (iOS 3.0) Property

    The selector defining the action message to invoke when users tap the accessory view.

    Deprecation Statement

    Instead use the tableView:commitEditingStyle:forRowAtIndexPath: or tableView:accessoryButtonTappedForRowWithIndexPath: for handling taps on cells.

    Declaration

    Objective-C

    @property(nonatomic) SEL accessoryAction

    Discussion

    If you specify a selector for the accessory action, a message is sent only if the accessory view is a detail disclosure button—that is, the cell's accessoryType property is assigned a value ofUITableViewCellAccessoryDetailDisclosureButton. If the value of this property is NULL, no action message is sent.

    The accessory view is a UITableViewCell-defined control, framework control, or custom control on the right side of the cell. It is often used to display a new view related to the selected cell. If the accessory view inherits from UIControl, you may set a target and action through the addTarget:action:forControlEvents: method. See accessoryView for more information.

    Import Statement

    Availability

    Available in iOS 2.0 and later.

    Deprecated in iOS 3.0.

    See Also

    target
    editAction

  • An enumeration for the various styles of cells.

    Declaration

    Swift

    enum UITableViewCellStyle : Int { case Default case Value1 case Value2 case Subtitle }

    Objective-C

    typedef enum : NSInteger { UITableViewCellStyleDefault, UITableViewCellStyleValue1, UITableViewCellStyleValue2, UITableViewCellStyleSubtitle } UITableViewCellStyle;

    Constants

    • Default

      UITableViewCellStyleDefault

      A simple style for a cell with a text label (black and left-aligned) and an optional image view. Note that this is the default style for cells prior to iOS 3.0.

      Available in iOS 3.0 and later.

    • Value1

      UITableViewCellStyleValue1

      A style for a cell with a label on the left side of the cell with left-aligned and black text; on the right side is a label that has smaller blue text and is right-aligned. The Settings application uses cells in this style.

      Available in iOS 3.0 and later.

    • Value2

      UITableViewCellStyleValue2

      A style for a cell with a label on the left side of the cell with text that is right-aligned and blue; on the right side of the cell is another label with smaller text that is left-aligned and black. The Phone/Contacts application uses cells in this style.

      Available in iOS 3.0 and later.

    • Subtitle

      UITableViewCellStyleSubtitle

      A style for a cell with a left-aligned label across the top and a left-aligned label below it in smaller gray text. The iPod application uses cells in this style.

      Available in iOS 3.0 and later.

    Discussion

    In all these cell styles, the larger of the text labels is accessed via the textLabel property and the smaller via the detailTextLabel property.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.0 and later.

  • The style of selected cells.

    Declaration

    Swift

    enum UITableViewCellSelectionStyle : Int { case None case Blue case Gray case Default }

    Objective-C

    typedef enum : NSInteger { UITableViewCellSelectionStyleNone, UITableViewCellSelectionStyleBlue, UITableViewCellSelectionStyleGray, UITableViewCellSelectionStyleDefault } UITableViewCellSelectionStyle;

    Constants

    • None

      UITableViewCellSelectionStyleNone

      The cell has no distinct style for when it is selected.

      Available in iOS 2.0 and later.

    • Blue

      UITableViewCellSelectionStyleBlue

      The cell has a default background color when selected.

      In iOS 7, the selection color is no longer blue. Use UITableViewCellSelectionStyleDefault instead.

      Available in iOS 2.0 and later.

    • Gray

      UITableViewCellSelectionStyleGray

      Then cell when selected has a gray background.

      Use UITableViewCellSelectionStyleDefault instead.

      Available in iOS 2.0 and later.

    • Default

      UITableViewCellSelectionStyleDefault

      The cell selection style to use for tables. This is the default value.

      Available in iOS 7.0 and later.

    Discussion

    You use these constants to set the value of the selectionStyle property.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The editing control used by a cell.

    Declaration

    Swift

    enum UITableViewCellEditingStyle : Int { case None case Delete case Insert }

    Objective-C

    typedef enum : NSInteger { UITableViewCellEditingStyleNone, UITableViewCellEditingStyleDelete, UITableViewCellEditingStyleInsert } UITableViewCellEditingStyle;

    Constants

    • None

      UITableViewCellEditingStyleNone

      The cell has no editing control. This is the default value.

      Available in iOS 2.0 and later.

    • Delete

      UITableViewCellEditingStyleDelete

      The cell has the delete editing control; this control is a red circle enclosing a minus sign.

      Available in iOS 2.0 and later.

    • Insert

      UITableViewCellEditingStyleInsert

      The cell has the insert editing control; this control is a green circle enclosing a plus sign.

      Available in iOS 2.0 and later.

    Discussion

    You use them to set the value of the editingStyle property.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The type of standard accessory control used by a cell.

    Declaration

    Swift

    enum UITableViewCellAccessoryType : Int { case None case DisclosureIndicator case DetailDisclosureButton case Checkmark case DetailButton }

    Objective-C

    typedef enum : NSInteger { UITableViewCellAccessoryNone, UITableViewCellAccessoryDisclosureIndicator, UITableViewCellAccessoryDetailDisclosureButton, UITableViewCellAccessoryCheckmark, UITableViewCellAccessoryDetailButton } UITableViewCellAccessoryType;

    Constants

    • None

      UITableViewCellAccessoryNone

      The cell does not have any accessory view. This is the default value.

      Available in iOS 2.0 and later.

    • DisclosureIndicator

      UITableViewCellAccessoryDisclosureIndicator

      The cell has an accessory control shaped like a chevron. This control indicates that tapping the cell triggers a push action. The control does not track touches.

      Available in iOS 2.0 and later.

    • DetailDisclosureButton

      UITableViewCellAccessoryDetailDisclosureButton

      The cell has an info button and a chevron image as content. This control indicates that tapping the cell allows the user to configure the cell’s contents. The control tracks touches.

      Available in iOS 2.0 and later.

    • Checkmark

      UITableViewCellAccessoryCheckmark

      The cell has a check mark on its right side. This control does not track touches. The delegate of the table view can manage check marks in a section of rows (possibly limiting the check mark to one row of the section) in its tableView:didSelectRowAtIndexPath: method.

      Available in iOS 2.0 and later.

    • DetailButton

      UITableViewCellAccessoryDetailButton

      The cell has an info button without a chevron. This control indicates that tapping the cell displays additional information about the cell’s contents. The control tracks touches.

      Available in iOS 7.0 and later.

    Discussion

    You use these constants when setting the value of the accessoryType property.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Constants used to determine the new state of a cell as it transitions between states.

    Declaration

    Swift

    struct UITableViewCellStateMask : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var DefaultMask: UITableViewCellStateMask { get } static var ShowingEditControlMask: UITableViewCellStateMask { get } static var ShowingDeleteConfirmationMask: UITableViewCellStateMask { get } }

    Objective-C

    typedef enum : NSUInteger { UITableViewCellStateDefaultMask = 0, UITableViewCellStateShowingEditControlMask = 1 << 0, UITableViewCellStateShowingDeleteConfirmationMask = 1 << 1 } UITableViewCellStateMask;

    Constants

    • DefaultMask

      UITableViewCellStateDefaultMask

      The normal state of a table cell.

      Available in iOS 3.0 and later.

    • ShowingEditControlMask

      UITableViewCellStateShowingEditControlMask

      The state of a table view cell when the table view is in editing mode.

      Available in iOS 3.0 and later.

    • ShowingDeleteConfirmationMask

      UITableViewCellStateShowingDeleteConfirmationMask

      The state of a table view cell that shows a button requesting confirmation of a delete gesture.

      Available in iOS 3.0 and later.

    Discussion

    The methods that use these constants are didTransitionToState: and willTransitionToState:.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.0 and later.

  • The style for cells used as separators.

    Declaration

    Swift

    enum UITableViewCellSeparatorStyle : Int { case None case SingleLine case SingleLineEtched }

    Objective-C

    typedef enum : NSInteger { UITableViewCellSeparatorStyleNone, UITableViewCellSeparatorStyleSingleLine, UITableViewCellSeparatorStyleSingleLineEtched } UITableViewCellSeparatorStyle;

    Constants

    • None

      UITableViewCellSeparatorStyleNone

      The separator cell has no distinct style.

      Available in iOS 2.0 and later.

    • SingleLine

      UITableViewCellSeparatorStyleSingleLine

      The separator cell has a single line running across its width. This is the default value

      Available in iOS 2.0 and later.

    • SingleLineEtched

      UITableViewCellSeparatorStyleSingleLineEtched

      The separator cell has double lines running across its width, giving it an etched look. This style is currently only supported for grouped-style table views.

      Available in iOS 3.2 and later.

    Discussion

    You use these constants to set the value of the separatorStyle property defined by UITableView.

    Import Statement

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Synonyms for certain table-view cell constants.

    Declaration

    Objective-C

    #define UITableViewCellSeparatorStyleDoubleLineEtched UITableViewCellSeparatorStyleSingleLineEtched #define UITableViewCellStateEditingMask UITableViewCellStateShowingEditControlMask

    Constants

    • UITableViewCellSeparatorStyleDoubleLineEtched

      UITableViewCellSeparatorStyleDoubleLineEtched

      The separator cell has double lines running across its width, giving it an etched look. This style is currently only supported for grouped-style table views.

    • UITableViewCellStateEditingMask

      UITableViewCellStateEditingMask

      The state of a table view cell when the table view is in editing mode.

      Available in iOS 3.0 and later.

    Import Statement