Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 8 Crash - renderInContext:UIGraphicsGetCurrentContext()

Before iOS 8, I didn't have problems with this & now, yes.

LOG:

Assertion failed: (CGFloatIsValid(x) && CGFloatIsValid(y)), function void CGPathMoveToPoint(CGMutablePathRef, const CGAffineTransform *, CGFloat, CGFloat), file Paths/CGPath.cc, line 254.

This is my code:

UIImage* image = nil;

CGSize imageSize = CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height);

UIGraphicsBeginImageContextWithOptions(imageSize, NO , 0.0f);

[self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; // <- ERROR

image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

My purpose is to convert the view to image.

like image 815
A. Trejo Avatar asked Oct 19 '22 21:10

A. Trejo


1 Answers

Check for empty rectangles in what you're drawing, whether the view's bounds or the layer's content rectangle. I have noticed that assertion failure on iOS 8 where, before, empty rectangles were silently ignored.

I've added a number of...

if (!CGRectIsEmpty(bounds)) {
}

...conditions in my drawing.

like image 110
Phillip Mills Avatar answered Nov 01 '22 17:11

Phillip Mills