代码之家  ›  专栏  ›  技术社区  ›  David

为什么在指定旋转时CGPDFPageGetDrawingTransform()与SigaBrt崩溃?

  •  0
  • David  · 技术社区  · 15 年前

    当我使用rotation参数调用cgpdfagegetdrawingtransform()时,应用程序崩溃。如果我指定不旋转,就不会发生碰撞。

    这是我的Drawlayer:InContext:方法:

    - (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context
    {
    CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
        CGRect boundingBox = CGContextGetClipBoundingBox(context); 
        CGContextFillRect(context, boundingBox);
    
        //convert to UIKit native coodinate system
        CGContextTranslateCTM(context, 0.0, self.bounds.size.height);
    CGContextScaleCTM(context, 1.0, -1.0);
    
        //Rotate the pdf_page
        CGAffineTransform pfd_transform = CGPDFPageGetDrawingTransform(self.page, kCGPDFCropBox, self.frame, 58.46f, true);
    
        CGContextSaveGState (context);
        CGContextConcatCTM (context, pfd_transform);
        CGContextClipToRect (context, self.frame);
        CGContextDrawPDFPage (context, self.page);
        CGContextRestoreGState (context);
    }
    

    从长远来看,我希望动态旋转PDF以跟踪用户标题。也许我错了…

    谢谢你抽出时间。

    1 回复  |  直到 15 年前
        1
  •  1
  •   Ole Begemann    15 年前

    从文档中 CGPDFPageGetDrawingTransform :

    CGAffineTransform CGPDFPageGetDrawingTransform (CGPDFPageRef page, CGPDFBox box, CGRect rect, int rotate, bool preserveAspectRatio);

    参数

    rotate 一个整数,必须是90的倍数,指定指定矩形顺时针旋转的角度。

    58.46f 既不是整数,也不是90的倍数。