I have a UIImageView
within an UIViewController
and want to add a simple image on the existing imageView.
The viewDidLoad-method looks like this:
UIImage *test;
test = [UIImage imageNamed:@"position-dot.png"];
[test drawAtPoint:CGPointMake(100,100) ];
A part of the error-message I receive look like this:
CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
CGContextSetBlendMode: invalid context 0x0. This is a serious error
.
I tested to reset my iOS Simulator (solution in other threads about this), but that didn't fix the problem.
While the approach in my above comment does silence the warning, I was finding that the image was not displaying as I expected. I found that the easiest way to make drawAtPoint work was to subclass UIView and put the exact code that you have into the implementation of drawRect: like so.
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
UIImage *test;
test = [UIImage imageNamed:@"position-dot"];
[test drawAtPoint:CGPointMake(100.0, 100.0)];
}
Then, in your controller:
MyViewSubclass *view = [[MyViewSubclass alloc] initWithFrame:self.view.frame];
[self.view addSubview:view];