1
我需要在iOS中創建一個包含多個圖像的單頁pdf文件。我用這個代碼:在iOS中創建一個包含圖像陣列的單頁pdf文件?
- (void)createPDFWithImagesArray:(NSMutableArray *)array andFileName:(NSString *)fileName
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *PDFPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.pdf",fileName]];
for (UIImage *image in array)
{
// Mark the beginning of a new page.
CGRect pagebounds=CGRectMake(0, 0, image.size.width, image.size.height);
CGRect imagebounds=CGRectMake(0, 0, image.size.width, image.size.height);
UIGraphicsBeginPDFContextToFile(PDFPath, pagebounds, nil);
{
UIGraphicsBeginPDFPage();
[image drawInRect:imagebounds];
}
}
UIGraphicsEndPDFContext();
}
但不生成PDF文件,並收到錯誤任何機構可以幫我請...
有什麼錯誤? – NobodyNada 2014-12-05 05:18:24
[1094:190271 ***終止應用程序由於未捕獲的異常「NSInvalidArgumentException」,原因是:「 - [__ NSArrayM大小]:無法識別的選擇發送到實例0x15e84a70」 – 2014-12-05 05:35:39
確定該應用在這個方法塊崩潰? – Esha 2014-12-05 05:38:48