Hi List,

I have created a custom MKAnnotationView, which allows the user to move the 
MKAnnotationView. My problem is that the showCallOut does not show the 
subTitle. I am not sure what I am missing.

Here is my .h

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>

@interface ViewShedAnnotationView : MKAnnotationView{
     UIImageView *customPin;

}
@property (nonatomic, retain)  UIImageView *customPin;

@end

Here is my .m

#import "ViewShedAnnotationView.h"

@implementation ViewShedAnnotationView
@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, 12);        
        self.rightCalloutAccessoryView = [UIButton 
buttonWithType:UIButtonTypeDetailDisclosure];
    }
        return self;
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {      
    
  
    UITouch *myTouch = [[event allTouches] anyObject];   
    self.center = [myTouch locationInView:self.superview];      
    
    [super touchesBegan:touches withEvent:event];
    
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    
    UITouch* aTouch = [touches anyObject];
    CGPoint newLocation = [aTouch locationInView:[self superview]];  
    self.center = newLocation;
    
    [super touchesMoved:touches withEvent:event];               
        
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
   
    [super touchesEnded:touches withEvent:event];
        
}

@end

Here is how I am instantiating it in my view controller:

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id 
<MKAnnotation>) mannotation{
    
    ViewShedAnnotationView *annView=[[ViewShedAnnotationView alloc] 
initWithAnnotation:mannotation reuseIdentifier:@"currentloc"];
    
    annView.calloutOffset = CGPointMake(-5, 5);
    return annView;
}       

Thank you for the help.

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