例外一個模版cell:(壓縮包中 3.jpg)
4、實現如下代碼:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
MessageSection0TableViewCell *cell = (MessageSection0TableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"message_section0"]; //直接通過標飾獲取cell
cell.NotifiLb.text = notifArr[indexPath.row];
return cell;
}
if (indexPath.section == 1) {
MessageSection1TableViewCell *cell = (MessageSection1TableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"message_section1"];
FriendObj *obj = friendsArr[indexPath.row];
cell.NameLb.text = obj.f_name;
cell.introLb.text = obj.f_intro;
cell.HeaderIView.image = [UIImage imageNamed:@"icon_100"];
return cell;
}
return nil;
}