0
좋아요. 주석을 잘 보여 주지만 작은 대화 상자를 표시하는 방법을 알아낼 수 없습니다. 특수 효과를 만들 때 다음을 수행합니다.주석 위에 표시 할 세부 정보를 얻으려면
다시 말하면,이 기능은 제대로 작동하지만 작은 대화 상자는 표시되지 않습니다.
저는 대리인과 관련이 있다는 것을 알고 있습니다. Apple의 MapCallouts 예제 코드를 다운로드하여 주석에 대리인과 어떻게 연락했는지 파악할 수 없었습니다. 여기
는Annotation.H 내 주석 클래스입니다
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface Annotation : NSObject <MKAnnotation>{
CLLocationCoordinate2D coordinate;
NSString *title;
NSString *subtitle;
}
@property (nonatomic) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
-(id)initWithCoordinate:(CLLocationCoordinate2D) c
title:(NSString *) t
subtitle:(NSString *) st;
-(void) moveAnnotation: (CLLocationCoordinate2D) newCoordinate;
-(NSString *)subtitle;
-(NSString *)title;
@end
Annotation.m 여기
#import "Annotation.h"
@implementation Annotation
@synthesize coordinate = _coordinate;
@synthesize title = _title;
@synthesize subtitle = _subtitle;
-(id)initWithCoordinate:(CLLocationCoordinate2D)c title:(NSString *)t subtitle:(NSString *)st
{
coordinate = c;
self.title = t;
self.subtitle = st;
return self;
}
-(void)moveAnnotation:(CLLocationCoordinate2D)newCoordinate
{
coordinate = newCoordinate;
}
-(NSString *)subtitle {
return subtitle;
}
-(NSString *)title{
return title;
}
@end
내가 설정 한 delagate입니다 :
-(MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[Annotation class]])
{
static NSString *reuseId = @"customAnn";
MKAnnotationView *customAnnotationView = [aMapView dequeueReusableAnnotationViewWithIdentifier:reuseId];
if (customAnnotationView == nil)
{
customAnnotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseId];
UIImage *pinImage = [UIImage imageNamed:@"pin-green.png"];
[customAnnotationView setImage:pinImage];
customAnnotationView.canShowCallout = YES;
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
customAnnotationView.rightCalloutAccessoryView = rightButton;
}
customAnnotationView.annotation = annotation;
return customAnnotationView;
}
return nil;
}
는 경우 정보가 더 필요하다. 내게있어, 미리 알려 주시고 고맙습니다.
내지도보기에 대한 대리인을 설정하려면 어떻게해야하나요? –
이렇게, 맞지? : @ interface MapViewController : UIViewController –
예. 실제로 mapView의 delegate 속성을 설정해야합니다. (mapView.delegate = self;) –