解決策: SDWebImage を使用します: https://github.com/rs/SDWebImage
スクロール中に非常に遅くなる UITableView があります。使用している画像が画面に戻ってくるときにラグが発生することを発見しました。
カスタム UITableViewCell を使用しています。これも遅れている理由でしょうか?
私のカスタム UITableViewCell:
私のコード:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = [NSString stringWithFormat:@"Cell%d%d",indexPath.row,indexPath.section];
tableViewCellActiviteiten *cell = (tableViewCellActiviteiten *)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"tableViewCellActiviteiten" owner:self options:nil];
cell = (tableViewCellActiviteiten *)[nib objectAtIndex:0];
}
cell.thetitle.text = [self.alletitels objectAtIndex:indexPath.row];
cell.thesubtitle.text = [self.allesubtitels objectAtIndex:indexPath.row];
NSString * imagePath = [self.alleimages objectAtIndex:indexPath.row];
NSURL * imageURL = [NSURL URLWithString:imagePath];
NSData * imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage * image = [UIImage imageWithData:imageData];
cell.image.image = image;
return cell;
}
配列の内容:
self.alletitels
次の文字列が含まれています: "Activity Title"
self.allesubtitels
「Activity Subtitle」という文字列が含まれています
self.alleimages
次の URL が含まれています: " http://m2.myhappygames.com//files/pics/0/Paranormal_Shark_Activity_3.jpg "
遅延スクロールの原因は何か、誰にもアドバイスできますか?