自己的应用中需要一种非普通格式的cell,于是自己就定义了一下;基本上的代码类似如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
static NSString *captionCellWithIdentifier = @"captionCell";

//使用自定义的cell模板
static BOOL nibRegistered = NO;
if(!nibRegistered){
UINib *nib = [UINib nibWithNibName:@"captionCell" bundle:nil];
[self.personTable registerNib:nib forCellReuseIdentifier:captionCellWithIdentifier];
nibRegistered = YES;
}


captionCell *cell = [self.personTable dequeueReusableCellWithIdentifier:captionCellWithIdentifier];
if(cell == nil){
cell = [[captionCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:captionCellWithIdentifier];
}


cell.contentView.backgroundColor = [UIColor grayColor];

cell.firstTitle.text = @"3月4日 艺人新媒体指数";
cell.firstTitle.textColor = [UIColor whiteColor];
cell.secondTitle.text = @"www.vlinkage.com";
cell.secondTitle.textColor = [UIColor whiteColor];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
return cell;