Skip to content
Search

IOS:UITableViewCell

lastmod 2018-08-17created 2014-02-1012 edits

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.

Touch Animation Trouble

When you touch a custom UITableViewCell, it can sometimes get stuck in the Touch Down Animation.

UITableViewCell_Normal_Image.png

->

UITableViewCell_Touch_Down_Image.png

In this case, check the Override method below.

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

Comment out code like the following.

// [super setSelected:selected animated:animated];

Hight of UITableViewCell

You can change the Cell height of a UITableView, and there are two ways to do it. One is to use the heightForRowAtIndexPath method, which most books introduce. The other is to set a value in the rowHeight property, and the effect is different. Changing the height with heightForRowAtIndexPath lets you give each cell a different height, because indexPath is passed in as an argument.... To change them all at once, of course, just return a constant. But if you only do this, when there are no cells at all, the height becomes the default table view height instead of the height returned by the heightForRowAtIndexPath method. In other words, if I set the height to 70 in heightForRowAtIndexPath but there are no cells, the height becomes 40. In this case, if you also set rowHeight to 70, the empty cell height is 70 even when there are no cells. In short, rowHeight is the default height, and heightForRowAtIndexPath is for applying a different height to each cell.

Transparency Background

To apply a transparent color to the background, apply it as shown below.

cell.backgroundColor = [UIColor clearColor];

This is not verified, but starting with iOS7 the transparent background color must be set separately.

See also

Favorite site

References


  1. IPhone_8_-_Custom_Cell.pdf ↩

  2. Creating_Custom_UITableViewCell_using_Nib_files_in_XCode.pdf ↩