UITableView를 사용하여 iPad 앱용 레이아웃과 같은 그리드 (스프레드 시트)를 만들고 있습니다. 그리드 파트가 작동하지만, 동적으로 UILabels을 셀에 추가하기 때문에 재사용 가능한 부분이 잘 작동하지 않습니다.UITableView GridLayout 재사용 가능한 UITableViewCell의 문제
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FundCell"];
Fund *fund = [funds objectAtIndex:[indexPath row]];
float labelWidth = 1024/([columnNames count] -1);
for(NSString *columnName in columnNames)
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x, 0, labelWidth, 44)];
label.backgroundColor = [UIColor clearColor];
label.text = [fund valueForKey:columnName];
x += label.bounds.size.width;
[cell addSubview:label];
}
x = 0;
return cell;
}
결과 :
'UITableView' 인스턴스를 여러 개 생성하는 대신'UICollectionView'를 사용하지 마십시오. –
여러 개의 UITableView 인스턴스를 생성하지 않습니다 !!! – azamsharp
죄송합니다. 내가 틀 렸습니다 –