UITableView
,在其中使用了2个prototype
cell,在这些原型单元格中又使用了1个UITextField
。现在当我运行应用程序并在第一个原型单元格中输入值时,然后滚动
UITableView
,那么第一个原型单元格的textfield值就会替换为最后一个原型单元格的textfield值。所以每次我向下或向上滚动时都会发生这种情况。有时它会变成空白。这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==0)
{
Client_MobileCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier_MobileCell forIndexPath:indexPath];
cell.lblTitle.text = [arrTitle objectAtIndex:indexPath.row];
cell.txtMobile.placeholder = [arrPlaceholder objectAtIndex:indexPath.row];
// cell.txtMobile.tag = indexPath.row+100;
return cell;
}
else
{
// Client_Common_Cell *cell = (Client_Common_Cell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier_CommonCell forIndexPath:indexPath];
Client_Common_Cell *cell = (Client_Common_Cell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier_CommonCell];
// cell.txtCommon.tag = indexPath.row+100;
cell.delegate = self;
if(indexPath.row == 1 || indexPath.row == 2 || indexPath.row == 3 || indexPath.row == 4){
if(indexPath.row == 2)
cell.txtCommon.secureTextEntry = YES;
else if(indexPath.row == 4){
cell.txtCommon.keyboardType = UIKeyboardTypeEmailAddress;
}
cell.imgArrow.hidden = YES;
cell.btnSelection.hidden = YES;
}
else{
cell.btnSelection.hidden = NO;
cell.imgArrow.hidden = NO;
}
cell.lblTitle.text = [arrTitle objectAtIndex:indexPath.row];
cell.txtCommon.placeholder = [arrPlaceholder objectAtIndex:indexPath.row];
return cell;
}
}