• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[iPhone] add touches to MKAnnotationView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iPhone] add touches to MKAnnotationView


  • Subject: [iPhone] add touches to MKAnnotationView
  • From: Philip Vallone <email@hidden>
  • Date: Wed, 18 Aug 2010 20:42:14 -0400

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

  • Follow-Ups:
    • Re: [iPhone] add touches to MKAnnotationView
      • From: Philip Vallone <email@hidden>
  • Prev by Date: Best way to draw large tiled images?
  • Next by Date: Re: [iPhone] add touches to MKAnnotationView
  • Previous by thread: Re: Best way to draw large tiled images?
  • Next by thread: Re: [iPhone] add touches to MKAnnotationView
  • Index(es):
    • Date
    • Thread