我的代码如下.我得到的错误是
断言失败:(s-> stack-> next!= NULL),函数CGGStackRestore,文件Context/CGGStack.c,第116行.
码:
CGPDFPageRef page = CGPDFDocumentGetPage(document, i+1);
CGRect pageRect = CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
CGFloat pdfScale = width/pageRect.size.width;
pageRect.size = CGSizeMake(pageRect.size.width*pdfScale, pageRect.size.height*pdfScale);
pageRect.origin = CGPointZero;
UIGraphicsBeginImageContext(pageRect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
// White BG CGContextSetRGBFillColor(context, 1.0,1.0,1.0,1.0); CGContextFillRect(context,pageRect); CGContextSaveGState(context);
CGContextTranslateCTM(context, 0.0, pageRect.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(page, kCGPDFMediaBox, pageRect, 0, true));
CGContextDrawPDFPage(context, page);
CGContextRestoreGState(context);
UIImage *thm = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSLog(@"Image %@",thm);
pdfImage = [[UIImageView alloc] initWithImage:thm];
NSLog(@"Image View: %@",pdfImage);
[self.view addSubview:pdfImage];
[self.view reloadInputViews
];
Run Code Online (Sandbox Code Playgroud)
请帮忙.
这段代码不起作用,我不明白这个错误.请帮忙.
-(UIImage *)addText:(UIImage *)img text:(NSString *)text1
{
int w = img.size.width;
int h = img.size.height;
//lon = h - lon;
char* text = (char *)[text1 cStringUsingEncoding:NSASCIIStringEncoding];
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
/*UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
CGContextShowTextAtPoint(UIGraphicsGetCurrentContext(), 50, 100, text, strlen(text));
UIImage *viewImage =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSLog(@"View Image : %@",viewImage);*/
CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);
CGContextDrawImage(context, CGRectMake(0, 0, w, h), img.CGImage);
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1);
//char* text = (char *)[text1 cStringUsingEncoding:NSASCIIStringEncoding];// "05/05/09";
CGContextSelectFont(context, "Arial", 18, kCGEncodingMacRoman); …Run Code Online (Sandbox Code Playgroud) 我想使用AESEncryption在Iphone中加密和解密文件.它适用于NSData.但是如果我把数据放在块中,我的文件就会变得很好.我该怎么做呢.我能够使用commoncrypto库加密和解密数据.但是当我尝试以块的形式读取数据时会出现问题.
先感谢您.请帮忙.我需要尽快实现.