여기 내 코드입니다, 내 응용 프로그램에서 UITableView의 각 셀에 대해 사용자 지정 UITableViewCell을 사용하고 "heightForRowAtIndexPath"에서 셀 높이를 계산합니다. 그러나 "dequeueReusableCellWithIdentifier"를 사용하면 셀이 테이블보기를 스크롤 할 때 겹칩니다. . "dequeueReusableCellWithIdentifier"를 사용하지 않으면 사라집니다. 이 문제가 왜 발생하는지 모르시겠습니까?UITableView "dequeueReusableCellWithIdentifier"셀 내용에 기반한 동적 셀 높이의 셀 겹침 현상이 발생합니까?
실제로 "dequeueReusableCellWithIdentifier"를 사용하여 셀을 만들지는 알고 싶습니다. Tableview에 많은 셀이 표시되면 메모리 문제가 발생합니까?
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
// Return the number of rows in the section.
return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* cellIdentifier = @"threadCell";
SYGBBSTableViewCell * cell=nil;
//if I comment below line code , the cell overlap issue solved
cell = (SYGBBSTableViewCell*) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[SYGBBSTableViewCell alloc] initMessagingCellWithReuseIdentifier:cellIdentifier];
}
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
-(void)configureCell:(SYGBBSTableViewCell*)cell atIndexPath:(NSIndexPath *)indexPath {
SYGBBSTableViewCell* ccell = (SYGBBSTableViewCell*)cell;
...
cell.content.text=content;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath;
{
/// Here you can set also height according to your section and row
NSDictionary* thread = [MyGoController getBBSThreadAtIndex:indexPath.row];
int height = [SYGBBSTableViewCell cellHeightForThreadAt:thread];
return height;
}
당신은'체크 할 필요가없는 경우 (셀 = = nil)' – meda
@meda 나는 그가 dequeue 라인을 테스트 할 수 있도록 주석을 달 수 있도록 이것을한다고 생각한다. – danh
@sureone은 IB에서 SYGBBSTableViewCell로 설정된 프로토 타입 셀의 클래스입니까? 그렇지 않다면 문제를 설명 할 수 있습니다. – danh