0
自定义设计的分隔符问题我的问题是我想在我的UITableview单元格(indexPath.row=0
)的第一个单元格之外添加自定义设计的分隔符行。下面的代码看起来很好,当我第一次重新加载我的表。但是,当我向下滚动并向上滚动时,它会在表的第一个单元格的顶部出现自定义分隔线。我打印indexpath.row
值,发现如果我滚动表格的第一个单元格在indexpath.row=7
重建。任何解决方案谢谢:)我的代码的答复是:UItableview在indexpath.row = 0
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCellIdentifier";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = (CustomCell *)[CustomCell cellFromNibNamed:@"CustomTwitterCell"];
}
if(indexPath.row!=0)
{
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 2.5)];
lineView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"line.png"]];
[cell.contentView addSubview:lineView];
[lineView release];
}
NSDictionary *tweet;
tweet= [twitterTableArray objectAtIndex:indexPath.row];
cell.twitterTextLabel.text=[tweet objectForKey:@"text"];
cell.customSubLabel.text=[NSString stringWithFormat:@"%d",indexpath.row];
}
谢谢,它的工作:) – user1951145