- (instancetype)cellWithTableView:(UITableView *)tableView
{
static NSString *ID = @”tg”;
MJTgCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
if (cell == nil) {
// 从xib中加载cell
cell = [[[NSBundle mainBundle] loadNibNamed:@”MJTgCell” owner:nil options:nil] lastObject];
}
return cell;
}
在程序中调用该方法
// 1.创建cell
MJMessageCell *cell = [MJMessageCell cellWithTableView:tableView];
// 2.给cell传递模型
cell.messageFrame = self.messageFrames[indexPath.row];
// 3.返回cell
return cell;