Reputation: 12444
In my app I get the following errors in the console:
May 1 22:06:59 iPhone-4S app[93660] <Error>: CGContextAddPath: invalid context 0x0
May 1 22:06:59 iPhone-4S app[93660] <Error>: clip: invalid context 0x0
The only areas in which this can be occurring is in either of the following two methods to resize or add rounded edges to a UIImage. Here are the methods:
- (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize {
// Create a graphics image context
UIGraphicsBeginImageContext(newSize);
// Tell the old image to draw in this new context, with the desired
// new size
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
// Get the new image from the context
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
// End the context
UIGraphicsEndImageContext();
// Return the new image.
return newImage;
}
- (UIImage*)roundCorneredImage: (UIImage*)orig radius:(CGFloat) r {
UIGraphicsBeginImageContextWithOptions(orig.size, NO, 0);
[[UIBezierPath bezierPathWithRoundedRect:(CGRect){CGPointZero, orig.size}
cornerRadius:r] addClip];
[orig drawInRect:(CGRect){CGPointZero, orig.size}];
UIImage* result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return result;
}
Both methods are called from within UIViewControllers and I am positive the UIImage is not nil.
Is there any reason for this to be happening?
Thanks!
Upvotes: 0
Views: 1337