• 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] Subclass MKAnnotationView - subtitle missing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iphone] Subclass MKAnnotationView - subtitle missing


  • Subject: [iphone] Subclass MKAnnotationView - subtitle missing
  • From: Philip Vallone <email@hidden>
  • Date: Sun, 22 Aug 2010 10:09:02 -0400

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 (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

  • Prev by Date: Re: Core Data Lightweight Migration Woes
  • Next by Date: Bonjour, domains and MobileMe
  • Previous by thread: Re: Formatting float numbers
  • Next by thread: Bonjour, domains and MobileMe
  • Index(es):
    • Date
    • Thread