У меня есть UITableView, и в каждой ячейке отображается UIImage, созданный из pdf. Но сейчас производительность очень плохая. Вот мой код, который я использую для создания UIImage из PDF.Увеличение производительности на iphone при рендеринге pdf
Создание CGPDFDocumentRef и UIImageView (в cellForRowAtIndexPath метод):
...
CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), (CFStringRef)formula.icon, NULL, NULL);
CGPDFDocumentRef documentRef = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
CFRelease(pdfURL);
UIImageView *imageView = [[UIImageView alloc] initWithImage:[self imageFromPDFWithDocumentRef:documentRef]];
...
Сформировать UIImage:
- (UIImage *)imageFromPDFWithDocumentRef:(CGPDFDocumentRef)documentRef {
CGPDFPageRef pageRef = CGPDFDocumentGetPage(documentRef, 1);
CGRect pageRect = CGPDFPageGetBoxRect(pageRef, kCGPDFCropBox);
UIGraphicsBeginImageContext(pageRect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, CGRectGetMinX(pageRect),CGRectGetMaxY(pageRect));
CGContextScaleCTM(context, 1, -1);
CGContextTranslateCTM(context, -(pageRect.origin.x), -(pageRect.origin.y));
CGContextDrawPDFPage(context, pageRef);
UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return finalImage;
}
Что я могу сделать, чтобы increas скорость и держать память низким?
Привет, я делаю как ваш. Я не знаю, что такое code.icon в коде. пожалуйста, не могли бы вы предоставить больше ?. ТГц –