저는 UITableView를 가지고 있으며 셀에 사용자 정의보기를 추가하고 있습니다. 그것은 단지 2 개의 셀로 뒤져 있습니다. 마치 위아래로 스크롤 할 때 나는 그것이 더듬 거리는 것을 볼 수 있습니다/이것은 (iPhone 4s에있는) 많이 뒤떨어졌습니다. 나는 앱 스토어 앱을 보았고 매우 복잡한 tableviewcell으로 스크롤하는 것이 부드럽다. 내가 뭔가 잘못하고 있는거야? 내가있는 UITableViewController를로드 할 때UITableView는 실제로 단지 2 셀로 뒤떨어져 있습니다.
이- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
int row = [indexPath row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
UILabel *labelBarcode = [[UILabel alloc] initWithFrame:CGRectMake(80, 7, 150, 15)];
[labelBarcode setFont:[UIFont fontWithName:@"Helvetica-Bold" size:16]];
[labelBarcode setTag:10];
UILabel *labelLength = [[UILabel alloc] initWithFrame:CGRectMake(80, 22, 150, 15)];
[labelLength setFont:[UIFont fontWithName:@"Helvetica" size:14]];
[labelLength setTag:11];
UILabel *labelThickness = [[UILabel alloc] initWithFrame:CGRectMake(80, 37, 150, 15)];
[labelThickness setFont:[UIFont fontWithName:@"Helvetica" size:14]];
[labelThickness setTag:12];
UILabel *labelDiameter = [[UILabel alloc] initWithFrame:CGRectMake(190, 22, 100, 15)];
[labelDiameter setFont:[UIFont fontWithName:@"Helvetica" size:14]];
[labelDiameter setTag:13];
UILabel *labelCoating = [[UILabel alloc] initWithFrame:CGRectMake(190, 37, 100, 15)];
[labelCoating setFont:[UIFont fontWithName:@"Helvetica" size:14]];
[labelCoating setTag:14];
UIImageView *thumbView = [[UIImageView alloc] initWithFrame:CGRectMake(4, 4, 65, 50)];
[thumbView setContentMode:UIViewContentModeScaleToFill];
[thumbView setTag:15];
[[cell contentView] addSubview:thumbView];
[[cell contentView] addSubview:labelBarcode];
[[cell contentView] addSubview:labelLength];
[[cell contentView] addSubview:labelThickness];
[[cell contentView] addSubview:labelDiameter];
[[cell contentView] addSubview:labelCoating];
[thumbView release];
[labelBarcode release];
[labelLength release];
[labelThickness release];
[labelDiameter release];
[labelCoating release];
}
UILabel *labelBarcode = (UILabel *)[[cell contentView] viewWithTag:10];
UILabel *labelLength = (UILabel *)[[cell contentView] viewWithTag:11];
UILabel *labelThickness = (UILabel *)[[cell contentView] viewWithTag:12];
UILabel *labelDiameter = (UILabel *)[[cell contentView] viewWithTag:13];
UILabel *labelCoating = (UILabel *)[[cell contentView] viewWithTag:14];
UIImageView *thumbView = (UIImageView *)[[cell contentView] viewWithTag:15];
NSDictionary *pipe = [pipes objectAtIndex:row];
NSString *stringBarcode = [pipe objectForKey:@"Barcode"];
NSString *stringLength = [NSString stringWithFormat:@"Length: %@", [pipe objectForKey:@"Length"]];
NSString *stringThickness = [NSString stringWithFormat:@"Wall: %@",[pipe objectForKey:@"Thickness"]];
NSString *stringCoating = [NSString stringWithFormat:@"Coating: %@", [pipe objectForKey:@"Coating"]];
NSString *stringDiameter = [NSString stringWithFormat:@"Diameter: %@",[pipe objectForKey:@"Diameter"]];
[labelBarcode setText:stringBarcode];
[labelLength setText:stringLength];
[labelThickness setText:stringThickness];
[labelDiameter setText:stringDiameter];
[labelCoating setText:stringCoating];
[thumbView setImage:[UIImage imageWithData:[pipe objectForKey:@"Thumbnail"]]];
return cell;
}
지체 특히 발생합니다
여기 내 코드입니다. 내가 아무것도 할당 아니에요, 난 단지 (plist에서) 응용 프로그램이로드되고, 전체 애플 리케이션 메모리 소비가 1.56 메가 바이트에있는 데이터를 할당합니다.
각 파이프가 아마도 다른 축소판을 가지고 있기 때문에 이는 적절하지 않습니다. 여전히 코드를 메인 스레드에서 실행하고 있는데, 이것은 성능을 죽일 것입니다. –
Ahh ok - 코드를 잘못 읽었습니다. 실수였습니다. thumbview가 항상 동일하다는 인상을 받았습니다. – barfoon