Different types of TableView in iOS
TableView is a frequently used View in iOS development. For different display requirements, we need different cells for display. For more complex display, we usually customize the Cell style, however, you can simply display the list types supported by iOS.
Currently, iOS supports the following list types:
UITableViewCellStyleDefault: default type, which can display images and text UITableViewCellStyleSubtitle: displays images, text, and sub-text UITableViewCellStyleValue1: displays images, text, and sub-text UITableViewCellStyleValue2
Their display styles are also different, as shown in the following order: it is easy to set, the Code is as follows:
-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath {UITableViewCell * cell; // there are four types of switches (indexPath. row) {case 0: // UITableViewCellStyleDefault: default type. images and text can be displayed. {NSString * CellOne = @ "CellOne "; // set tableview type cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CellOne]; // you cannot click cell. selectionStyle = UITableViewCellSelectionStyleNone; cell. imageView. image = [UIImage imageNamed: @ "icon"]; // image cell. textLabel. text = @ "textLabel"; // text} break; case 1: // UITableViewCellStyleSubtitle type, supports displaying images, text, and subtexts {NSString * CellTwo = @ "CellTwo "; // set tableview type cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier: CellTwo]; // you cannot click cell. selectionStyle = UITableViewCellSelectionStyleNone; cell. imageView. image = [UIImage imageNamed: @ "icon"]; // image cell. textLabel. text = @ "textLabel"; // text cell. detailTextLabel. text = @ "detailTextLabel"; // subtext} break; case 2: // UITableViewCellStyleValue1 type. It supports displaying images, text, and subtext {NSString * CellThree = @ "CellThree "; // set tableview type cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleValue1 reuseIdentifier: CellThree]; // you cannot click cell. selectionStyle = UITableViewCellSelectionStyleNone; cell. imageView. image = [UIImage imageNamed: @ "icon"]; // image cell. textLabel. text = @ "textLabel"; // text cell. detailTextLabel. text = @ "detailTextLabel"; // subtext} break; case 3: // UITableViewCellStyleValue2 type; supports displaying text and subtext {NSString * CellFour = @ "CellFour "; // set tableview type cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleValue2 reuseIdentifier: CellFour]; // you cannot click cell. selectionStyle = UITableViewCellSelectionStyleNone; cell. textLabel. text = @ "textLabel"; // text cell. detailTextLabel. text = @ "detailTextLabel"; // subtext} break;} return cell ;}