- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
IssueViewCell *cell = (IssueViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[IssueViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
IssueData *issueData = [self.items objectAtIndex:indexPath.row];
[cell setData:issueData];
return cell;
}
在上个函数 [cell setData:issueData] 里给UItableViewCell的各个元素赋值,如果有些元素在特殊情况下不显示,那么需要把这些view要移除父视图的。
for (UIView *view in self.subviews) {
[view removeFromSuperview];
}
。而设置tableviewcell里元素的位置是在- (void)layoutSubviews函数里实现的,每次滑动的时候都会执行该函数的。