Данные проконтролированы, когда я прокручиваю UITableView - PullRequest
0 голосов
/ 20 января 2011

Я использую следующий код в cellForRowAtIndexPath: (NSIndexPath *) метод indexPath

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if(currentRow >=[finalArray count]) return cell;
// Configure the cell.


for(int ii=0;ii<[keys count];ii++){
NSString *no22=[dict objectForKey:[keys objectAtIndex:ii]];
no=[NSString stringWithFormat:@"%@ %"[keys objectAtIndex:ii],]  
}// end of the for loop


if(searching) 
    cell.text = [copyListOfItems objectAtIndex:indexPath.row];
else {
cell.text=[finalArray objectAtIndex:currentRow];

    currentRow=currentRow+1;
}
    return cell;

}

Я получаю странное поведение, когда прокручиваю таблицу, данные полностью неуправляемы, пожалуйсталюбое предложение.

1 Ответ

2 голосов
/ 20 января 2011

Это потому, что вы повторно используете ячейки. Вы можете повторно использовать больше типов клеток.

А почему вы делаете if(currentRow >=[finalArray count]) return cell; это?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...