0
我想創建一個PDF文件出現錯誤,但我得到2個錯誤:的iOS創建一個PDF
<Error>: CGDataConsumerCreateWithFilename: failed to open `/test.pdf' for writing: Operation not permitted. deflateEnd: error -3: (null).
而這一次
<Error>: CGPDFContextCreate: failed to create PDF context delegate.
我計算控制器類
路徑- (void)viewDidLoad
{
documentName = @"test.pdf";
NSArray *arrayPaths =
NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString *path = [arrayPaths objectAtIndex:0];
NSString* pdfFileName = [path stringByAppendingPathComponent:documentName];
url = [NSURL fileURLWithPath:pdfFileName];
PDFRenderer *pdf = [[PDFRenderer alloc]initWithFileName:documentName];
[pdf renderPDF];
[super viewDidLoad];
}
,並在呈現類我稱之爲
UIGraphicsBeginPDFContextToFile(documentName, CGRectZero, nil);
功能和我得到的錯誤。
我該如何解決該錯誤?
你應該調用'[super viewDidLoad];'首先,而不是最後。 – Holly