Corrected UITableViewCell text disappears when scrolling a table

I have UITableViewwith custom cells, these cells contain some text fields. Here, when I enter some data in textFields, and I look at the table view data, it disappears, I think, because every time I create a new cell.

I solved this problem by using an array and inserting each cell into it, but here I cannot reuse the cells, so we are losing memory.

Can you tell me how I should deal with this behavior?

+3
source share
2 answers

, , tableView:cellForRowAtIndexPath:. , , ( , ).

, UITableView's, :

NSString *identifier = @"reuseIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
}
cell.textLabel.text = @"text relating to index path";

tableView, , . , no. , initWithStyle:reuseIdentifier:, , , . , - , , .

, textField.text nil - , , , indexPath, .

+1

- (UITableViewCell *)tableView:(UITableView *)tTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

+5

All Articles