0
나는 NSXMLParser
을 사용하여 읽은 XML 파일의 데이터를 사용하여 채울 UITableView
을 가지고 있습니다. 내 UITableview
스크롤이 매우 느리고 약 10 개의 섹션과 15 개의 행 (각 섹션에 약 2 개) 만 있습니다.이미지가없는 UITableview 느린 스크롤
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//Declare the cell identifier for reuse
static NSString *SectionsTableIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SectionsTableIdentifier];
//Check if the table view cell has been created
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:SectionsTableIdentifier] autorelease];
}
CSCustomCellBackgroundView *cellBackgound = [[CSCustomCellBackgroundView alloc] init];
cellBackgound.position = CustomCellBackgroundViewPositionPlain;
cell.selectedBackgroundView = cellBackgound;
[cellBackgound release];
//Sort the years descending
allKeys = [[listofnews allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"]autorelease]];
[dateFormatter setDateFormat:@"dd/MM/yyyy"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
NSDate *obj1Date;
NSDate *obj2Date;
obj1Date = [dateFormatter dateFromString:[NSString stringWithFormat:@"%@%@",@"01/",obj1]];
obj2Date = [dateFormatter dateFromString:[NSString stringWithFormat:@"%@%@",@"01/",obj2]];
NSComparisonResult result = [obj2Date compare:obj1Date];
return result;
}];
aKey = [allKeys objectAtIndex:indexPath.section];
NSArray *sortedRowsbyDate = [[listofnews objectForKey:aKey] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"]autorelease]];
[dateFormatter setDateFormat:@"dd/MM/yyyy"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
NSDate *obj1Date;
NSDate *obj2Date;
obj1Date = [dateFormatter dateFromString:[NSString stringWithFormat:@"%@%@",@"01/",obj1]];
obj2Date = [dateFormatter dateFromString:[NSString stringWithFormat:@"%@%@",@"01/",obj2]];
NSComparisonResult result = [obj2Date compare:obj1Date];
return result;
}];
cell.textLabel.text = [[sortedRowsbyDate objectAtIndex:indexPath.row] objectForKey:@"sTitle"];
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.detailTextLabel.text = [[sortedRowsbyDate objectAtIndex:indexPath.row] objectForKey:@"sDescription"];
cell.detailTextLabel.numberOfLines = 2;
cell.detailTextLabel.lineBreakMode = UILineBreakModeTailTruncation;
cell.textLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
cell.detailTextLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
tableView.separatorColor = [UIColor colorWithRed: (109.0/255) green: (159.0/255) blue: (0.0/255) alpha: 1.0f];
return cell;}
가 나는 지연의 원인이 내 세포에서 어떤 이미지를 가지고 있지 않는 한 느린 스크롤의 원인이 무엇인지 결정하기 위해 여러분의 도움이 필요합니다 다음과 같이 cellForRowAtIndexPath
에 내 코드입니다. 내가하는 정렬인가?
제발 도와주세요 ... 시간 내 주셔서 감사합니다.