奇怪的感觉是,如果我想在一个控制器上预览一个pdf,除了一个图像,我唯一能让它工作的方法就是使用一个自定义的自定义的视图控制器,也许我不清楚。如何使图像显示在QuickLook操作的预览中,而不需要切换到视图中,而不仅仅是模态?这合乎逻辑吗?
我开发了一个生成PDF的应用程序,我给用户提供了预览them....but的可能性,当这些image....boom有一个image....boom时,图像就会从preview...unless上消失--我用的是一个索引--那么就没问题了,不过看起来很奇怪。如有任何建议?....thanks提前.
发布于 2015-08-15 07:58:34
- (CFRange)renderPage:(NSInteger)pageNum withTextRange:(CFRange)currentRange
andFramesetter:(CTFramesetterRef)framesetter
{
CGContextRef currentContext = UIGraphicsGetCurrentContext();
// Put the text matrix into a known state. This ensures
// that no old scaling factors are left in place.
CGContextSetTextMatrix(currentContext, CGAffineTransformIdentity);
// Create a path object to enclose the text. Use 72 point
// margins all around the text.
#pragma-----------here to disclose the height of text on pdf preview
CGRect frameRect = CGRectMake(40, 72, 468, 350);
CGMutablePathRef framePath = CGPathCreateMutable();
CGPathAddRect(framePath, NULL, frameRect);
[_imageView1 setImage:theImage1];
CGRect frame = CGRectMake(40, 50, 130, 130);
[ProgramPDFViewController drawImage:theImage1 inRect:frame];
CGSize size = theImage1.size;
CGFloat ratio = 0;
if (size.width > size.height) {
ratio = 44.0 / size.width;
} else {
ratio = 44.0 / size.height;
}
CGRect rect = CGRectMake(0.0, 0.0, ratio * size.width, ratio * size.height);
UIGraphicsBeginImageContext(rect.size);
[theImage1 drawInRect:rect];
UIGraphicsEndImageContext();
CTFrameRef frameRef = CTFramesetterCreateFrame(framesetter, currentRange, framePath, NULL);
CGPathRelease(framePath);
CGContextTranslateCTM(currentContext, 0, kDefaultPageHeight);
CGContextScaleCTM(currentContext, 1.0, -1.0);
CTFrameDraw(frameRef, currentContext);
currentRange = CTFrameGetVisibleStringRange(frameRef);
currentRange.location += currentRange.length;
currentRange.length = 0;
CFRelease(frameRef);
return currentRange;
}https://stackoverflow.com/questions/32003035
复制相似问题