Iphone Quartz PDF基于上下文的函数失败(偶尔),访问错误
当我调用此Quartz函数时,我经常会得到一个足够坏的访问:Iphone Quartz PDF基于上下文的函数失败(偶尔),访问错误,iphone,objective-c,cocoa-touch,ipad,ios,Iphone,Objective C,Cocoa Touch,Ipad,Ios,当我调用此Quartz函数时,我经常会得到一个足够坏的访问: CGContextDrawPDFPage ((CGContextRef)context, (CGPDFPageRef)pageRef); 我这样称呼它: CGContextRef context = UIGraphicsGetCurrentContext(); //translate, scale CGPDFPageRef myPageRef = CGPDFDocumentGetPage ([PDFDocument sharedPD
CGContextDrawPDFPage ((CGContextRef)context, (CGPDFPageRef)pageRef);
我这样称呼它:
CGContextRef context = UIGraphicsGetCurrentContext();
//translate, scale
CGPDFPageRef myPageRef = CGPDFDocumentGetPage ([PDFDocument sharedPDFDocument].documentData, pageNumber);
CGContextDrawPDFPage (context, myPageRef);//BAD_ACCESS HERE
return UIGraphicsGetImageFromCurrentImageContext();//autoreleased- saved on return
//close context
两个变量都不是零,或者都已释放/自动释放
以下是来自调试器的堆栈跟踪:
有人能解释一下吗?甚至还有一些关于如何更好地调查这一问题的建议。它甚至可能不是特定于函数的。
我可能应该提到这个函数是在一个单独的线程上执行的。检查文档中返回您的
myPageRef
,看看您是否必须保留它。在写问题时,UIGraphicsGetImageFromCurrentImageContext和那些线程不安全的函数,这是我的问题。从iOs 4.1+开始,许多UI功能现在都是线程安全的