Hi all
I am having trouble finding the properties for an custom object i made and added to an UIImageView. See the code below.
This is the interface for my custom class, for now it only holds the location of my UIImageView.
Code:
@interface monsterImage : UIImageView {
CGPoint startLocation;
}
@property(nonatomic) CGPoint startLocation;
@end
Here i add the view
Code:
CGRect myImageRect = CGRectMake(50, 50, 65, 65);
monsterImage *myImage = [[monsterImage alloc] initWithFrame:myImageRect];
myImage.opaque = YES;
[myImage setUserInteractionEnabled:YES];
[myImage setImage:[UIImage imageNamed:@"Monster.png"]];
[myImage setStartLocation:CGPointMake(50,50)]; //set location on monsterImage object.
[self.view addSubview:myImage];
In my touchesBegan i would like to do something like this:
Code:
UITouch *touch = [touches anyObject];
NSLog(@"UIImageView touched.");
// line below does not compile!
NSLog(@"Location: %i,%i", (int) [[touch view] startLocation].x, (int)[[touch view] startLocation].y);
Since the view is just an UIImageView getting startLocation is not working, but how do i get a hold of my "monsterImage" object which i added as a subview above?
Thanks in advance for any help.