UITableview 그룹화 된 스타일의 두 섹션에 하나의 문제점이 있습니다. 첫 번째 섹션은 6 개의 행을, 두 번째 섹션은 3 개의 행을가집니다. 내가 테이블 뷰를 위아래로 스크롤하면 섹션 2의 마지막 행 내용이 첫 번째 섹션의 첫 번째 행에 추가되고 첫 번째 섹션의 첫 번째 행 컨텐트가 두 번째 섹션의 마지막 행에 추가됩니다. 내용을로드하기 위해 셀이 비어 있는지 여부를 가장 잘 확인하지만 디버깅 중에는 발생하지 않습니다. 내 코드는iPhone에서 UITableview 섹션을 덮어 쓰시겠습니까?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.backgroundColor = [UIColor whiteColor];
if (indexPath.section == 0 && indexPath.row == 0)
{
UILabel *Nameabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 140, 30)];
Nameabel.text = @"Name";
Nameabel.font = [UIFont fontWithName:@"Helvetica" size:15];
Nameabel.backgroundColor = [UIColor clearColor];
Nameabel.font = [UIFont boldSystemFontOfSize:15];
[cell.contentView addSubview:Nameabel];
textField = [[UITextField alloc] initWithFrame:CGRectMake(145, 5, 150, 30)];
textField.placeholder = @"Student Name";
textField.borderStyle = UITextBorderStyleNone;
textField.font = [UIFont fontWithName:@"Helvetica" size:14];
[cell.contentView addSubview:paymentCatTextField];
}
else if (indexPath.section == 1 && indexPath.row == 0)
{
UILabel *RLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 140, 30)];
RLabel.text = @"Class";
RLabel.backgroundColor = [UIColor clearColor];
RLabel.font = [UIFont fontWithName:@"Helvetica" size:15];
RLabel.font = [UIFont boldSystemFontOfSize:15];
[cell.contentView RLabel];
RTextField = [[UITextField alloc] initWithFrame:CGRectMake(145, 5, 150, 30)];
RTextField.placeholder = @"class Name";
RTextField.borderStyle = UITextBorderStyleNone;
RTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
RTextField.font = [UIFont fontWithName:@"Helvetica" size:14];
[cell.contentView addSubview:RTextField];
}
}
return cell;
}
이것은 샘플입니다. 이 방식으로 섹션 0은 6 개의 행을 가지며 섹션 1은 3 개의 행을가집니다. 내가 잘못하고있는 곳. 제발이 문제를 해결하는 데 도움이됩니다.
미리 감사드립니다.
세포는주의 깊게 사과의 문서를 읽어야한다, 성능을 개선하기 위해 재사용 및 jQuery과에 대한 부분은 기본적와 중요성이다. –