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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to