안녕하세요.UITableView는 셀을 다시 사용하지 않습니까?
3.1 앱의 테이블보기에 약간의 위기가 있습니다. 펜촉에서로드되는 일부 복잡한 tableViewCells가있는 테이블 뷰가 있으며 재사용되지 않습니다. 펜촉에서로드하는 것과 관련이 있다고 느껴지면서 간단한 사과 프로젝트 템플릿 코드를 사용하여 셀이 재사용되고 있는지 확인하기로 결정했습니다. 나는 탐색 기반 템플릿으로 시작하고 여기에 cellForRowAtIndexPath에 대한 코드입니다 :
- (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];
}
// Configure the cell.
cell.textLabel.text = [NSString stringWithFormat:@"%d", indexPath.row];
return cell;
}
내가 다음 줄에 중단 점 설정을 가지고, 그것은 모든 패스라고 얻고있다. 같은 생성자의 reuseIdentifier 설정
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]
:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] autorelease];
}
동일한 결과없이 셀 재사용을 산출한다.
미리 도움을 주셔서 감사합니다.
그래서 템플릿처럼 다시 사용하지 않습니까? 얼마나 많은 사과가 재사용에 대해 이야기했는지 좀 이상해 보입니다. – pzearfoss
다릅니다. 얼마나 많은 행이 있습니까? 표준 표는 한 번에 8 행 정도를 표시 할 수 있으므로 고유 한 객체 여야합니다. 그러나 20 개의 행을 말하면 여전히 8 개 정도의 객체 만 가질 수 있습니다. 객체를 볼 때 또는 볼 때 스크롤 할 때 재활용됩니다. – jbrennan