Моя проблема заключается в том, что я хочу добавить настраиваемую линию разделителя между моими ячейками UITableview, кроме первой ячейки таблицы (indexPath.row=0
). Следующий код кажется прекрасным, когда я перезагружаю таблицу в первый раз. Однако, когда я прокручиваю вниз и прокручиваю вверх, появляется строка пользовательского seperator в верхней части первой ячейки таблицы. Я напечатал значение 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