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


Try this:

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

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

Need Your Help

Excel macro to search multiple urls in one column

excel vba excel-vba

I have a worksheet (Sheet2) that contains 27 columns, first row is the columns headers which are A-Z and NUM totaling 27 cols. Each column has a very long list of restricted urls sorted to the lett...

Kendo Grid: scroll focused cell into view

jquery javascript-events kendo-ui kendo-grid

I have a Kendo Grid that is setup with Virtual Paging and Navigatable (for keyboard navigation). Depending on the size of the content, sometimes I will not be able to see all the data in the curren...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.