TableView problem... duplication of some array items.

Discussion in 'iOS Programming' started by moomy, Sep 13, 2010.

  1. moomy macrumors newbie

    Apr 28, 2010
    Hi there,

    I have this problem, my programme works a treat but when I scroll down the table view it is fine, but then, after it gets to the last cell from the array, if I continue to scroll down it duplicates some of the items which have already been displayed and puts them into cells again.

    The array is read from plist files.

    here is the method.

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return 1;
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return myList.count;
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    	// Configure the cell.
    	cell.textLabel.text = [myList objectAtIndex:indexPath.row];
    	cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        return cell;

    not sure if the problem is here?

    quite new to this and a bit confused. If anyone has any ideas that would be great.
  2. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    So, you're saying that your tableView is showing more rows than there are elements in your myList array? For example, your array contains 10 items but if you scroll down, the table displays 12 rows?
  3. Sykte macrumors regular

    Aug 26, 2010
    What does your plist look like. Also post the code you use to fill your array.
  4. moomy thread starter macrumors newbie

    Apr 28, 2010
    Thanks for replying. I have now figured it out. The scrolling enabled box in interface builder was checked by default. Once unchecked it seems to be working ok. :)

Share This Page