일부 버튼을 요소로 사용하여 테이블보기를 만들면 뷰가 잘로드되지만 아래로 스크롤하는 단추는 겹쳐서 표시됩니다. 나는 오래된 버튼이 지워지지 않고 새로운 버튼이 그 위에 위치한다고 생각한다. 이 문제를 해결하도록 도와주세요. 미리 감사드립니다.스크롤하는 동안 UIButton이있는 UITableViewCells가 있습니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath (NSIndexPath *)indexPath
{
NSLog(@"index path %ld",(long)indexPath.row);
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:[NSString stringWithFormat:@"data %ld",(long)indexPath.row] forState:UIControlStateNormal];
button.frame = CGRectMake(0, 0, 160.0, 25);
[cell.contentView addSubview:button];
return cell;
}
당신은 삭제할 수 있습니다 사용할 수있는 (셀 == 전무) 코드 블록이 dequeueReusableCellWithIdentifier 이미 충분합니다. – etolstoy