Я создал собственную ячейку.Когда я использую эти пользовательские ячейки в табличном представлении Мои ячейки заменяются. Я создал около 10 разделов в табличном представлении, в котором каждый раздел содержит 1 строку.Я использую Custom Cells для всех 10 разделов.Когда я прокручиваю вид, последние 4 ячейки заменяются верхними ячейками.Я использую ReuseIdentifier, но они все еще заменяются.Любые идеи, чтобы это исправить?Спасибо!
Это мой код CustomCell!
-(UITableViewCell *)returnCellForBirthdayDetails:(UITableView *)tableView
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CustomCellForBirthdayDetails"];
if(cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:@"CustomCellToAddDetails" owner:self options:nil];
cell = customCell;
// customCell = nil;
}
return cell;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[customCellTextField resignFirstResponder];
return YES;
}
- (UITextField *)textField
{
UITextField *textField = nil;
if( customCell )
{
textField = (UITextField *)[customCell.contentView viewWithTag:101];
}
return textField;
}
и здесь я вызываю пользовательские ячейки в tableView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
addCustomCell = [[CustomCellToAddDetailsController alloc] init];
switch (indexPath.section)
{
case 0:
cell = [addCustomCell returnCellForBirthdayDetails:tableView];
addCustomCell.customCellLabel.text = @"FirstName";
addCustomCell.customCellLabel.font = [UIFont boldSystemFontOfSize:12];
addCustomCell.customCellTextField.placeholder = @"FirstName";
[delegate.fieldArray addObject:addCustomCell];
break;
case 1:
cell = [addCustomCell returnCellForBirthdayDetails:tableView];
addCustomCell.customCellLabel.text = @"LastName";
addCustomCell.customCellLabel.font = [UIFont boldSystemFontOfSize:12];
addCustomCell.customCellTextField.placeholder = @"LastName";
[delegate.fieldArray addObject:addCustomCell];
break;
case 2:
cell = [addCustomCell returnCellForBirthdayDetails:tableView];
addCustomCell.customCellLabel.text = @"Dob";
addCustomCell.customCellLabel.font = [UIFont boldSystemFontOfSize:12];
addCustomCell.customCellTextField.placeholder = @"Dob";
addCustomCell.customCellTextField.inputView = dp;
addCustomCell.customCellTextField.inputAccessoryView=toolBarForTableView;
[delegate.fieldArray addObject:addCustomCell];
break;
case 3:
cell = [addCustomCell returnCellForBirthdayDetails:tableView];
addCustomCell.customCellLabel.text = @"Address";
addCustomCell.customCellLabel.font = [UIFont boldSystemFontOfSize:12];
addCustomCell.customCellTextField.placeholder = @"Enter Address";
[delegate.fieldArray addObject:addCustomCell];
break;
case 4:
cell = [addCustomCell returnCellForBirthdayDetails:tableView];
addCustomCell.customCellLabel.text = @"City";
addCustomCell.customCellLabel.font = [UIFont boldSystemFontOfSize:12];
addCustomCell.customCellTextField.placeholder = @"Enter City";
[delegate.fieldArray addObject:addCustomCell];
break;
case 5:
cell = [addCustomCell returnCellForBirthdayDetails:tableView];
addCustomCell.customCellLabel.text = @"State";
addCustomCell.customCellLabel.font = [UIFont boldSystemFontOfSize:12];
addCustomCell.customCellTextField.placeholder = @"Enter State";
[delegate.fieldArray addObject:addCustomCell];
break;
case 6:
cell = [addCustomCell returnCellForBirthdayDetails:tableView];
addCustomCell.customCellLabel.text = @"Email";
addCustomCell.customCellLabel.font = [UIFont boldSystemFontOfSize:12];
addCustomCell.customCellTextField.placeholder = @"Enter Email";
[delegate.fieldArray addObject:addCustomCell];
break;
case 7:
cell = [addCustomCell returnCellForBirthdayDetails:tableView];
addCustomCell.customCellLabel.text = @"Phone";
addCustomCell.customCellLabel.font = [UIFont boldSystemFontOfSize:12];
addCustomCell.customCellTextField.placeholder = @"Enter MobileNo";
[delegate.fieldArray addObject:addCustomCell];
break;
}
return cell;
[addCustomCell release];
}
Пожалуйста, дайте мне знать, какая я ошибкаизготовление.Спасибо !!