开发者

Error in iphone: Assertion failed: (s->stack->next != NULL), function CGGStackRestore, file Context/CGGStack.c, line 116

My code is as below. I get the error as

Assertion failed: (s->stack->next != NULL), function CGGStackRestore, file Context/CGGStack.c, line 116.

Code:

 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开发者_Go百科);
            [self.view addSubview:pdfImage];
            [self.view reloadInputViews
];

Please Help.


There is no CGContextSaveGState before CGContextRestoreGState!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜