Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios ***ImageIO-在创建PDF期间找不到ColorSync函数_Ios_Pdf_Core Graphics_Runtime Error - Fatal编程技术网

Ios ***ImageIO-在创建PDF期间找不到ColorSync函数

Ios ***ImageIO-在创建PDF期间找不到ColorSync函数,ios,pdf,core-graphics,runtime-error,Ios,Pdf,Core Graphics,Runtime Error,我正在尝试在我的应用程序中创建一个PDF,并且一切都正常,除了当我在模拟器或设备上运行我的项目时,我在一行代码上得到一个异常断点,该代码不会使应用程序崩溃,但会生成一个***ImageIO-找不到ColorSync函数“ColorSyncProfileCreateSanizedCopy”。在我继续执行之后,我得到了另一个异常断点,它仍然不会使应用程序崩溃,并且不会产生任何输出 下面是我用来绘制PDF的代码: +(void)drawText:(NSString *)textToDraw ofSiz

我正在尝试在我的应用程序中创建一个PDF,并且一切都正常,除了当我在模拟器或设备上运行我的项目时,我在一行代码上得到一个异常断点,该代码不会使应用程序崩溃,但会生成一个
***ImageIO-找不到ColorSync函数“ColorSyncProfileCreateSanizedCopy”
。在我继续执行之后,我得到了另一个异常断点,它仍然不会使应用程序崩溃,并且不会产生任何输出

下面是我用来绘制PDF的代码:

+(void)drawText:(NSString *)textToDraw ofSize:(CGFloat)textSize inFrame:(CGRect)frameRect andRotate:(BOOL)shouldRotate
{

    CFStringRef stringRef = (__bridge CFStringRef)textToDraw;
    // Prepare the text using a Core Text Framesetter
    CTFontRef font = CTFontCreateWithName (CFSTR("Helvetica"), textSize, NULL);
    NSDictionary *attributes = @{ (__bridge id)kCTFontAttributeName : (__bridge id) font };
    CFAttributedStringRef currentText = CFAttributedStringCreate(NULL, stringRef, (__bridge CFDictionaryRef)attributes);
    CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(currentText);


    CGMutablePathRef framePath = CGPathCreateMutable();
    CGPathAddRect(framePath, NULL, frameRect);

    // Get the frame that will do the rendering.
    CFRange currentRange = CFRangeMake(0, 0);
    CTFrameRef frameRef = CTFramesetterCreateFrame(framesetter, currentRange, framePath, NULL);
    CGPathRelease(framePath);

    // Get the graphics context.
    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);


    // Core Text draws from the bottom-left corner up, so flip
    // the current transform prior to drawing.
    CGContextTranslateCTM(currentContext, 0, frameRect.origin.y*2);
    CGContextScaleCTM(currentContext, 1.0, -1.0);

    if(shouldRotate){
        CGAffineTransform myTextTransform;
        myTextTransform =  CGAffineTransformMakeRotation  (90 / 180.0 * M_PI);
        CGContextSetTextMatrix (currentContext, myTextTransform);
    }

    // Draw the frame.
    CTFrameDraw(frameRef, currentContext); //This is where the exception breakpoint stops
                                           //*** ImageIO - could not find ColorSync function
                                           //'ColorSyncProfileCreateSanitizedCopy'

    CGContextScaleCTM(currentContext, 1.0, -1.0);
    CGContextTranslateCTM(currentContext, 0, (-1)*frameRect.origin.y*2);



    CFRelease(frameRef);
    CFRelease(stringRef);
    CFRelease(framesetter);
}
在我通过这些断点继续应用程序后,我会在此处获得更多异常断点:

libc++abi.dylib`__cxa_throw:
0x107726519:  pushq  %rbp  //BREAKPOINT IS ON THIS LINE
0x10772651a:  movq   %rsp, %rbp
0x10772651d:  pushq  %r15
0x10772651f:  pushq  %r14
0x107726521:  pushq  %r12
0x107726523:  pushq  %rbx
0x107726524:  movq   %rdx, %r14
0x107726527:  movq   %rsi, %r15
0x10772652a:  movq   %rdi, %rbx
0x10772652d:  callq  0x107726123               ; __cxa_get_globals
0x107726532:  movq   %rax, %r12
0x107726535:  callq  0x107726ab0               ; std::get_unexpected()
0x10772653a:  movq   %rax, -0x60(%rbx)
0x10772653e:  callq  0x107726aea               ; std::get_terminate()
0x107726543:  movq   %rax, -0x58(%rbx)
0x107726547:  movq   %r15, -0x70(%rbx)
0x10772654b:  movq   %r14, -0x68(%rbx)
0x10772654f:  leaq   -0x20(%rbx), %r14
0x107726553:  movabsq $0x434c4e47432b2b00, %rax
0x10772655d:  movq   %rax, -0x20(%rbx)
0x107726561:  movq   $0x1, -0x78(%rbx)
0x107726569:  incl   0x8(%r12)
0x10772656e:  leaq   0x1d(%rip), %rax          ; __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*)
0x107726575:  movq   %rax, -0x18(%rbx)
0x107726579:  movq   %r14, %rdi
0x10772657c:  callq  0x107729448               ; symbol stub for: _Unwind_RaiseException
0x107726581:  movq   %r14, %rdi
0x107726584:  callq  0x1077265b9               ; __cxa_begin_catch
0x107726589:  movq   -0x58(%rbx), %rdi
0x10772658d:  callq  0x107726af9               ; std::__terminate(void (*)())

一旦我继续通过这些断点,PDF实际上就被创建了,应用程序将继续正常运行。这些断点非常烦人,我不知道如何解决导致它们的问题。这在iOS 8.0及更高版本上发生。如有任何帮助,将不胜感激。

已解决。避免使用CTFrameDraw(frameRef,currentContext)或drawPageAtIndex:inRect:。并使用核心图形方式手动生成PDF。这似乎是iOS 8或更高版本中未记录的错误


有关更多详细信息,请参见

我在iOS 8上也遇到了同样的问题。在我使用CGContextDrawPDFPage()方法的行中,所有异常的断点不断中断,但它不会使应用程序崩溃。我还看到,
***ImageIO-在我的控制台日志中找不到ColorSync函数“ColorSyncProfileCreateSanizedCopy”
。我不太担心这一点,因为应用程序不会崩溃,但我觉得在未来的版本中这会导致崩溃。我也有同样的问题,但我没有处理PDF。。。我正在从文件扩展名为
.gif
的目录加载图像。显然它不喜欢这样,我只是选择了一个
.png
文件。没有更多的错误。这可能只是文件的格式化或压缩方式。。。不太清楚。。。我觉得这是一些低层次的调试,你必须潜入。。。特别是因为您处理Core Frameworksjsetting32的评论给了我解决方案:我对TIFF文件也有同样的问题。我把它转换成PNG,它解决了这个问题。