my problem is I want to add custom designed seperator line between my UITableview cells except first cell of table(indexPath.row=0
). Following code seems fine when I reload my table first time. However when I scroll down and scroll up it appears custom seperator line on the top of the first cell of table. I printed indexpath.row
value and discovered that if I scrolls up first cell of table is reconstructed at indexpath.row=7
. Any solution? Thanks for reply :) My code is:
- (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];
}