Renamed MGLCalloutView to MGLCompactCalloutView and MGLCalloutViewProtocol to MGLCalloutView to avoid an awkward workaround for a Swift name collision. Replaced individual title and subtitle properties with a single representedObject property that lets you use custom annotation properties in the custom callout view. Overrode a problematic SMCalloutView method. Added lots more documentation.
32 lines
655 B
Objective-C
32 lines
655 B
Objective-C
#import "MGLCompactCalloutView.h"
|
|
|
|
#import "MGLAnnotation.h"
|
|
|
|
@implementation MGLCompactCalloutView
|
|
{
|
|
id <MGLAnnotation> _representedObject;
|
|
}
|
|
|
|
@synthesize representedObject = _representedObject;
|
|
|
|
+ (instancetype)platformCalloutView
|
|
{
|
|
return [[self alloc] init];
|
|
}
|
|
|
|
- (void)setRepresentedObject:(id <MGLAnnotation>)representedObject
|
|
{
|
|
_representedObject = representedObject;
|
|
|
|
if ([representedObject respondsToSelector:@selector(title)])
|
|
{
|
|
self.title = representedObject.title;
|
|
}
|
|
if ([representedObject respondsToSelector:@selector(subtitle)])
|
|
{
|
|
self.subtitle = representedObject.subtitle;
|
|
}
|
|
}
|
|
|
|
@end
|