セルごとに画像を設定すると、アプリのスクロールが非常に遅くなります。SDImageWebプロジェクトを使用してみましたが、それでも同じようにゆっくりとスクロールし、セル上のすべての画像ビューが引き伸ばされてしまいます。これが行のセルの私のコードです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];
//root path of image...used to check if image exists for this article
NSString *substring = @"http://316apps.com/ipreachersblog/wp";
NSRange textRange = [entry.articleImage rangeOfString:substring];
if(textRange.location != NSNotFound){
NSString *thearticleImage = entry.articleImage;
NSRegularExpression *expression = [NSRegularExpression regularExpressionWithPattern:@"(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))" options:NSRegularExpressionCaseInsensitive error:NULL];
NSString *someString = thearticleImage;
NSString *oneurl = [someString substringWithRange:[expression rangeOfFirstMatchInString:someString options:NSMatchingCompleted range:NSMakeRange(0, [someString length])]];
NSURL *picimage = [NSURL URLWithString:oneurl];
UIFont *cellFont = [UIFont fontWithName:@"ArialRoundedMTBold" size:15];
UIFont *cellFont2 = [UIFont fontWithName:@"ArialRoundedMTBold" size:12];
NSData * urlData = [NSData dataWithContentsOfURL: picimage];
UIImage * imageweb = [UIImage imageWithData: urlData];
CGSize newSize = CGSizeMake(69, 69);
UIGraphicsBeginImageContext( newSize );
[imageweb drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CALayer * l = [cell.imageView layer];
[l setMasksToBounds:YES];
[l setCornerRadius:11];
[l setBorderWidth:2.0];
[l setBorderColor:[[UIColor blackColor] CGColor]];
cell.textLabel.text = entry.articleTitle;
cell.textLabel.font = cellFont;
cell.detailTextLabel.font = cellFont2;
cell.imageView.image = newImage;
cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
}
else {
//loads when no featured image present
}
return cell;
}
何か案は?