I am trying to do UIImage in Objective-C (working on a simple iPhone application (a thing like a breakthrough) to get used to the environment). However, I get the error "Error: CGContextDrawImage: invalid context" when I try to draw it.
My question is: how to set a context that uses the DrawAtPoint method for UIImage?
Here is the appropriate code for how I initialize / call everything:
@interface GameItem : NSObject { IBOutlet UIImage * sprite; CGPoint pos; } - (id) initWithPositionAndSprite: (CGPoint)placementPosition :(UIImage*) blockImage; - (void) update; @property CGPoint pos; @end
in update:
[sprite drawAtPoint:pos]
And initializing it as:
newBall = [[Ball alloc] initWithPositionAndSprite:CGPointMake(3.0, 4.0) :[UIImage imageNamed:@"ball.png"]];
(Ball inherits from GameItem until it does nothing else)
I get invalid context from drawAtPoint afaik call. Any help / pointers somewhere that explain how to set the context would be greatly appreciated.
Thanks!
objective-c iphone uiimage
Dashrantic
source share