In my application I am creating UITextField
within UITableViewCell
so that user can fill some information. This is my code:
if (![cell.contentView viewWithTag:10])
{
UITextField *textField=[[UITextField alloc]initWithFrame:CGRectMake(0, 0, 200, 30)];
[textField setTag:10];
[textField setBorderStyle:UITextBorderStyleRoundedRect];
[textField setBackgroundColor:[UIColor redColor]];
[cell.contentView addSubview:textField];
}
I am doing this so that I create that UITextField
only once for each cell so that the textFields don't overlap... but a problem happened for example when the user writes in the textfields:
row 0 -> 0
row 1 -> 1
row 2 -> 2
row 3 -> 3
row 4 -> 4
And so on, if you have number of rows more than 10 and you started to scroll I can notice that the cells exchange there indices randomly so i can get something like:
row 0 -> 3
row 1 -> 1
row 2 -> 2
row 3 -> 0
row 4 -> 4
in the UITextField.text how to make something or a trick like fixed position for each cell?