Re: [iPhone] add touches to MKAnnotationView
Re: [iPhone] add touches to MKAnnotationView
- Subject: Re: [iPhone] add touches to MKAnnotationView
- From: Philip Vallone <email@hidden>
- Date: Wed, 18 Aug 2010 20:50:45 -0400
Never mind... I got it.
Thanks,
Phil
On Aug 18, 2010, at 8:42 PM, Philip Vallone wrote:
> Hi,
>
> I have a subclass of MKAnnotationView,in which I create a custom pin (customPin, which is a UIImageView). I want to be able to move that custom Pin but I am having trouble. The touch event is being called, but my image is not moving.
>
> Here is my subclass:
>
>
> @implementation MyAnnotationView
> @synthesize customPin;
>
> - (void)dealloc {
> [customPin release];
> [super dealloc];
> }
>
> - (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier {
>
> if ((self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier])) {
> self.canShowCallout = YES;
>
> self.image = [UIImage imageNamed:@"Pin.png"];
> self.centerOffset = CGPointMake(8, -14);
> self.calloutOffset = CGPointMake(-8, 0);
>
> customPin = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Pin.png"]];
> customPin.frame = CGRectMake(0, 0, 32, 39);
> //customPin.hidden = YES;
> [self addSubview:customPin];
> }
> return self;
> }
>
> - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
>
> NSLog(@"Touch");
> UITouch *myTouch = [[event allTouches] anyObject];
> customPin.center = [myTouch locationInView:self.superview];
>
> [super touchesBegan:touches withEvent:event];
>
> }
>
>
> - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
>
> NSLog(@"Touch Ended");
>
> [super touchesEnded:touches withEvent:event];
>
> }
>
>
> @end
>
> I am not sure what I am missing. Any help would be greatly appreciated.
>
> Thanks
>
> Phil
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden