Ranjeet Sajwan
Ranjeet Sajwan

Reputation: 1921

Problem with table view in iPhone

Here is my code for creating a cell


cell.textLabel.text=[listdata objectAtIndex:indexPath.row ];
if(indexPath.row==1)
cell.detailTextLabel.text=@"Some text";
return cell;


Here are total 20 rows and only 8 rows are visible at a time

My problem is that detail text label it repeated at many rows when i do scrolling....

please help

Upvotes: 1

Views: 112

Answers (1)

Jeremy Fuller
Jeremy Fuller

Reputation: 3401

Try this:

cell.textLabel.text = [listdata objectAtIndex:indexPath.row];
if (indexPath.row == 1)
    cell.detailTextLabel.text = @"Some text";
else
    cell.detailTextLabel.text = @"";
return cell;

Table cells are recycled, so you have to reset everything every time.

Upvotes: 4

Related Questions