cell的主体内容风格有以下几种:
UITableViewCellStyleDefault,
UITableViewCellStyleValue1,
UITableViewCellStyleValue2,
UITableViewCellStyleSubtitle
可是他们只能在初始化时确定。之后就不能修改;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomCellIdentifier";
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
[cell setSelectionStyle:UITableViewCellSelectionStyleGray];
}
[[cell textLabel] setText:[tableData objectAtIndex:indexPath.row]];
return cell;
}
不过当CellIdentifier = nil;时就不会从cell池里拿到以前用过的cell了。这样每次刷新都可以从新初始化一个cell,同时确定他的主体内容风格。