У меня есть одно табличное представление с разделом, и в четвертом разделе я вставил mapview. Теперь я хочу отобразить текущую широту и долготу при нажатии на булавку. У меня есть широта и долгота. Пин появляется на карте, но когда я нажимаю на нее, я ничего не получаю. Код, который я написал, приведен ниже. Кто-нибудь может сказать, в чем здесь проблема? Любой пример кода или учебник для этого?
// Это файл для получения координат местоположения
#import "VolunteerDetailAnnotation.h"
@implementation VolunteerDetailAnnotation
@synthesize title;
@synthesize subtitle;
@synthesize coordinate;
/*-(id)init
{
self=[super init];
if(!self)
{
return nil;
}
self.title=nil;
self.subtitle=nil;
return self;
}*/
-(NSString *)gettitle
{
return title;
}
-(NSString *)getsubtitle
{
return subtitle;
}
-(id)initWithCoordinate:(CLLocationCoordinate2D)inCoord{
self = [self init];
self.coordinate = inCoord;
return self;
}
- (void)dealloc
{
self.title=nil;
self.subtitle=nil;
[super dealloc];
}
@end
В файле, в который вставлена карта
if(index.section==3)
{
mapView=[[MKMapView alloc] initWithFrame:frame22];
mapView.mapType=MKMapTypeStandard;
CLLocationCoordinate2D location = mapView.userLocation.coordinate;
MKCoordinateSpan span;
MKCoordinateRegion region;
location.latitude = [[aVolunteer latitude] floatValue];
location.longitude = [[aVolunteer longitude] floatValue];
mapView.scrollEnabled=YES;
span.latitudeDelta = 0.05;
span.longitudeDelta = 0.05;
mapView.showsUserLocation=YES;
region.span = span;
region.center = location;
VolunteerDetailAnnotation *placemark=[[VolunteerDetailAnnotation alloc] initWithCoordinate:location];
placemark.title=@"Current Location";
placemark.subtitle=[NSString stringWithFormat:@"%@: %@",aVolunteer.latitude,aVolunteer.longitude] ;
[mapView addAnnotation:placemark];
[mapView setRegion:region animated:YES];
[mapView regionThatFits:region];
[cell1 addSubview:mapView];
}
Спасибо!