我的表格中有一個很慢的滾動條,滾動條具有從網頁加載並調整大小,但圖像已加載的圖像,所以我不明白爲什麼滾動速度很慢。 我已閱讀並試圖slow scrolling of UITableView沒有成功(我看空細胞)在表格視圖中慢速滾動
這是細胞(它也有編碼區冠軍)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSString *[email protected]"";
NSString *icon;
NSMutableArray *result=[allResults objectAtIndex:indexPath.section];
NSDictionary *dic=[result objectAtIndex:indexPath.row+1];
if([[result objectAtIndex:0] isEqualToString:@"types"])
{
NSString *title=[dic objectForKey:@"title"];
icon=[dic objectForKey:@"icon"];
data=[data stringByAppendingString:[NSString stringWithFormat:@"%@",title]];
}
if([[result objectAtIndex:0] isEqualToString:@"subServices"])
{
NSString *title=[dic objectForKey:@"title"];
icon=[dic objectForKey:@"icon"];
data=[data stringByAppendingString:[NSString stringWithFormat:@"%@",title]];
}
if([[result objectAtIndex:0] isEqualToString:@"businesses"])
{
NSString *title=[dic objectForKey:@"title"];
icon=[dic objectForKey:@"logo"];
data=[data stringByAppendingString:[NSString stringWithFormat:@"%@",title]];
}
cell.textLabel.numberOfLines = 1;
cell.textLabel.text = data;
cell.textLabel.textColor=[UIColor blackColor];
cell.textLabel.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:22];
cell.textLabel.textColor=[UIColor colorWithRed:122.0/255.0 green:181.0/255.0 blue:196.0/255.0 alpha:1];
cell.imageView.layer.masksToBounds = YES;
//load image
NSURL *url = [NSURL URLWithString:icon];
NSData *imdata = [NSData dataWithContentsOfURL:url];
UIImage *logo=[UIImage imageWithData:imdata scale:1];
UIImage *scaled=[self resizeImage:logo imageSize:CGSizeMake(30, 30)];
cell.imageView.image=scaled ;
cell.imageView.layer.masksToBounds = YES;
cell.imageView.layer.cornerRadius = 12.0;
return cell;
}
您應該使用其他'/ if'(三個'if'測試consecutives)。你也可以看看延遲加載(加載你的URL圖像)。 – Larme