I want to plot the MKmapannotation by the photos - ios

Here is my code:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MapLocation *Annotation = annotation;
static NSString *identifier = #"MapLocation";
if ([annotation isKindOfClass:[MapLocation class]]) {
MKPinAnnotationView *annotationViewBus = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
MKPinAnnotationView *annotationViewTaxi = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
MKPinAnnotationView *annotationViewSam = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
MKPinAnnotationView *annotationViewMetro = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
//bus
if (!annotationViewBus ) {
annotationViewBus = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
annotationViewBus.enabled = YES;
annotationViewBus.canShowCallout = YES;
if (busStatus==YES) {
annotationViewBus.image=[UIImage imageNamed:#"annotationBus.png"];//here we use a nice image instead of the default pins
return annotationViewBus;
}else {
annotationViewBus.annotation = annotation;
}
}
//taxi
if (!annotationViewTaxi ) {
annotationViewTaxi = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
annotationViewTaxi.enabled = YES;
annotationViewTaxi.canShowCallout = YES;
if (taxiStatus==YES) {
annotationViewTaxi.image=[UIImage imageNamed:#"annotationTaxi.png"];//here we use a nice image instead of the default pins
// return annotationViewTaxi;
}else {
annotationViewTaxi.annotation = annotation;
}
}
//sam
if (!annotationViewSam ) {
annotationViewSam = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
annotationViewSam.enabled = YES;
annotationViewSam.canShowCallout = YES;
if(samStatus==YES){
annotationViewSam.image=[UIImage imageNamed:#"annotationSam.png"];
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:[Annotation name] forState:UIControlStateNormal];
[rightButton addTarget:self action:#selector(chatButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; //display another view
annotationViewSam.rightCalloutAccessoryView = rightButton;
// return annotationViewSam;
}else {
annotationViewSam.annotation = annotation;
}
}
//metro
if (!annotationViewMetro ) {
annotationViewMetro = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
annotationViewMetro.enabled = YES;
annotationViewMetro.canShowCallout = YES;
if(metroStatus==YES){
annotationViewMetro.image=[UIImage imageNamed:#"annotationMetro.png"];
}else {
annotationViewMetro.annotation = annotation;
}
//return annotationViewMetro;
}
}
return nil;
}

You have forgotten return (MKAnnotationView *) for each Annotation View type.
Just add return AnnotationView for each type. For example:
//metro
if (!annotationViewMetro ) {
annotationViewMetro = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
annotationViewMetro.enabled = YES;
annotationViewMetro.canShowCallout = YES;
if(metroStatus==YES){
annotationViewMetro.image=[UIImage imageNamed:#"annotationMetro.png"];
}else {
annotationViewMetro.annotation = annotation;
}
just uncomment this line:
return annotationViewMetro;
}

Related

How to use different MKAnnotationView for 2 different MKPointAnnotation on the same MKMapView

I have 2 MKPointAnnotation and i want to display them on map with two different pins(MKAnnotationView having image).
// MKPointAnnotation - 1
CLLocationCoordinate2D cordinate;
cordinate.latitude = [_latitudeString doubleValue];
cordinate.longitude = [_longitudeString doubleValue];
MKPointAnnotation *point1 = [[MKPointAnnotation alloc] init];
point1.coordinate = CLLocationCoordinate2DMake(cordinate.latitude, cordinate.longitude);
[self.mapView addAnnotation:point1];
P.S - When i get second MKPointAnnotation i needed self zoom on that area.
// MKPointAnnotation - 2
CLLocationCoordinate2D cordinate;
cordinate.latitude = [_latStr doubleValue];
cordinate.longitude = [_longStr doubleValue];
MKPointAnnotation *point2 = [[MKPointAnnotation alloc] init];
point2.coordinate = CLLocationCoordinate2DMake(cordinate.latitude, cordinate.longitude);
[self.mapView addAnnotation:point2];
//This is my code for MKAnnotationView
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
if ([annotation isKindOfClass:[MKPointAnnotation class]]){
MKAnnotationView *pinView = (MKAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:#"CustomPinAnnotationView"];
if(!pinView){
pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:#"CustomPinAnnotationView"];
pinView.canShowCallout = YES;
pinView.image = [UIImage imageNamed:#"annotation"];
pinView.calloutOffset = CGPointMake(0, 0);
}
else{
pinView.annotation = annotation;
}
return pinView;
}
return nil;
}
What i need to change in the viewForAnnotation method?
For example, you can create subclass of MKPointAnnotation.
#interface SecondAnnotation: MKPointAnnotation
#end
#implementation SecondAnnotation
#end
Add SecondAnnotation to the mapView.
// MKPointAnnotation - 2
...
SecondAnnotation *point2 = [[SecondAnnotation alloc] init];
point2.coordinate = CLLocationCoordinate2DMake(cordinate.latitude,
cordinate.longitude);
[self.mapView addAnnotation:point2];
You can use different MKAnnotationView with the following code.
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
if ([annotation isKindOfClass:[MKPointAnnotation class]]){
MKAnnotationView *pinView = (MKAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:#"CustomPinAnnotationView"];
if(!pinView){
pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:#"CustomPinAnnotationView"];
pinView.canShowCallout = YES;
pinView.image = [UIImage imageNamed:#"Annotation"];
pinView.calloutOffset = CGPointMake(0, 0);
}
else{
pinView.annotation = annotation;
}
return pinView;
} else if ([annotation isKindOfClass:[SecondAnnotation class]]){
MKAnnotationView *pinView = (MKAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:#"CustomPinAnnotationView"];
if(!pinView){
pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:#"CustomPinAnnotationView"];
pinView.canShowCallout = YES;
pinView.image = [UIImage imageNamed:#"Second"];
pinView.calloutOffset = CGPointMake(0, 0);
}
else{
pinView.annotation = annotation;
}
return pinView;
}
return nil;
}
Writing the viewForAnnotation as below solved my problem -
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
if ([annotation isKindOfClass:[MKPointAnnotation class]]){
MKAnnotationView *pinView = (MKAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:#"CustomPinAnnotationView"];
if(!pinView){
pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:#"CustomPinAnnotationView"];
pinView.canShowCallout = YES;
pinView.image = [UIImage imageNamed:#"annotation"];
pinView.calloutOffset = CGPointMake(0, 0);
}
else{
pinView.annotation = annotation;
if ([annotation isKindOfClass:[SecondAnnotation class]]) {
pinView.image = [UIImage imageNamed:#"range"];
}
else{
pinView.image = [UIImage imageNamed:#"annotation"];
}
}
return pinView;
}
return nil;
}

As user is moving i wanted to plot another mkannotation on his old position which is different than current annotation in objective-c

As user is moving i wanted to plot another mkannotation on his old position which is different than current annotation in objective-c
for which I have written code
-(void)plotDotted:(double)latitude :(double)longitude
{
_busOldAnnotation.coordinate = CLLocationCoordinate2DMake(latitude, longitude);
[self.sampleMap addAnnotation:_busOldAnnotation];
}
-(void)plotPoint:(double)latitude :(double)longitude
{
_busAnnotation.coordinate = CLLocationCoordinate2DMake(latitude, longitude);
[self.sampleMap addAnnotation:_busAnnotation];
}
Annotation Delegate
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
static NSString *Identifier = #"driverView";
MKAnnotationView* myAnnotation = [self.sampleMap dequeueReusableAnnotationViewWithIdentifier:Identifier];
if (myAnnotation == nil)
{
myAnnotation = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:Identifier];
//myAnnotation.enabled = YES;
}
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(_latituDouble, _longitudeDouble);
if (coordinate.latitude == _latituDouble && coordinate.longitude == _longitudeDouble)
{
myAnnotation.image = [UIImage imageNamed:#"bus_icon.png"];
}
else if (_busOldAnnotation)
{
myAnnotation.image = [UIImage imageNamed:#"blue_dot.png"];
}
return myAnnotation;
}
Called Functions
//1. Remove
[self removeAnnotation];
//3. Add new
[self plotPoint:latitudeDouble :longitudeDouble];
//2. Add Old
[self plotDotted:_latituDouble :_longitudeDouble];
//4. Assign that coordinate to global
_latituDouble = latitudeDouble;
_longitudeDouble = longitudeDouble;
[self.sampleMap reloadInputViews];
Everything is working fine that , user is moving on my map ,
Removing previous location,
but not able to add blue_dot image after that user is moving
Use this and see if it works
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(_latituDouble, _longitudeDouble);
if (coordinate.latitude == _latituDouble && coordinate.longitude == _longitudeDouble)
{
static NSString *Identifier1 = #"driverView";
MKAnnotationView* myAnnotation = [self.sampleMap dequeueReusableAnnotationViewWithIdentifier:Identifier1];
if (myAnnotation == nil)
{
myAnnotation = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:Identifier];
//myAnnotation.enabled = YES;
}
myAnnotation.image = [UIImage imageNamed:#"bus_icon.png"];
return myAnnotation;
}
else if (_busOldAnnotation)
{
static NSString *Identifier2 = #"driverView2";
MKAnnotationView* myAnnotation = [self.sampleMap dequeueReusableAnnotationViewWithIdentifier:Identifier2];
if (myAnnotation == nil)
{
myAnnotation = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:Identifier];
//myAnnotation.enabled = YES;
}
myAnnotation.image = [UIImage imageNamed:#"blue_dot.png"];
return myAnnotation;
}
return nil;
}

Adding action to MKMapView annotation

I have a MKMapView with a bunch of annotations but I can't add an action to them. I was just creating an MKPointAnnotation, but I couldn't add an action to that. Whenever I click the annotation, nothing happens. Here is how I am setting the annotations -
CLLocationCoordinate2D monteVista;
monteVista.latitude = (double) 37.83029;
monteVista.longitude = (double) -121.98827;
MKPointAnnotation *monteVistaPoint = [[MKPointAnnotation alloc] init];
monteVistaPoint.coordinate = monteVista;
monteVistaPoint.title = #"Monte Vista";
CLLocationCoordinate2D sanRamonValley;
sanRamonValley.latitude = (double) 37.82609;
sanRamonValley.longitude = (double) -122.00603;
MKPointAnnotation *sanRamonValleyPoint = [[MKPointAnnotation alloc] init];
sanRamonValleyPoint.coordinate = sanRamonValley;
sanRamonValleyPoint.title = #"San Ramon Valley";
CLLocationCoordinate2D doughertyValley;
doughertyValley.latitude = (double) 37.76845;
doughertyValley.longitude = (double) -121.90342;
MKPointAnnotation *doughertyValleyPoint = [[MKPointAnnotation alloc] init];
doughertyValleyPoint.coordinate = doughertyValley;
doughertyValleyPoint.title = #"Dougherty Valley";
NSArray *points = [[NSArray alloc] initWithObjects: monteVistaPoint, sanRamonValleyPoint, doughertyValleyPoint, nil];
[self.schoolMap addAnnotations:points];
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKPinAnnotationView *annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
NSLog(#"Pin Created");
return annotationView;
}
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
MKPointAnnotation *testPoint = [[MKPointAnnotation alloc] init];
testPoint = view.annotation;
self.testText.text = testPoint.title;
NSLog(#"Selected");
}
You need to change viewForAnnotation: method in order customize and then just implement openDetail: action method
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if (annotation == mapView.userLocation)
{
return nil;
}
static NSString *identifier = #"CustomAnnotation";
MKAnnotationView* annView = nil;
if ([annotation isKindOfClass:[CustomAnnotation class]]) {
annView = (MKAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annView == nil) {
annView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
} else {
annView.annotation = annotation;
}
UIImage *image = nil;
image = [UIImage imageNamed:#"pin2"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[annView addSubview:imageView];
[annView setFrame:CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)];
// [annView setBackgroundColor:[UIColor colorWithRed:1 green:0 blue:0 alpha:0.1]];
UIButton*accessory = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[accessory setTag:[(CustomAnnotation*)annotation tag]];
[accessory addTarget:self action:#selector(openDetail:) forControlEvents:UIControlEventTouchUpInside];
[accessory setFrame:CGRectMake(0, 0, 30, 30)];
[annView setRightCalloutAccessoryView:accessory];
}
[annView setEnabled:YES];
[annView setCanShowCallout:YES];
return annView;
}

iOS: Can we drop different color pins same time on Map

I want to different color pins on the map for example some pins should be red,some pins should be green and some pins should be purple.
I am using the below code, in this code at one time only one color pins will be dropped.
I want to know, can we drop different color pins same time in the Map
-(void)showMap
{
[map_View setZoomEnabled:YES];
[map_View setScrollEnabled:YES];
CLLocationCoordinate2D coordinate;
coordinate.latitude = 49.2802;
coordinate.longitude = -123.1182;
map_View.region = MKCoordinateRegionMakeWithDistance(coordinate, 2000, 2000);
// Set 10 random locations on the map for testing purposes
//
for(int i=0; i<10; i++) {
CGFloat latDelta = rand()*.035/RAND_MAX -.02;
CGFloat longDelta = rand()*.03/RAND_MAX -.015;
CLLocationCoordinate2D newCoord = { coordinate.latitude + latDelta, coordinate.longitude + longDelta };
RetailerAnnotation *ann = [[RetailerAnnotation alloc] initWithLocation:newCoord];
// ann.coordinate = newCoord;
//m_pinColor = #"BLUE";
if(i< 4)
{
m_pinColor = #"RED";
}
else if(i>=4 && i<7)
{
m_pinColor = #"BLUE";
}
else if(i>=7 && i<10)
{
m_pinColor = #"GREEN";
}
NSLog(#"pin color:%#",m_pinColor);
[ann setTitle:[NSString stringWithFormat:#"Title%d",i]];
[ann setSubtitle:[NSString stringWithFormat:#"subTitle%d",i]];
[map_View addAnnotation:ann];
[ann release];
}
}
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
static NSString *identifier = #"myPin";
MKPinAnnotationView *pinView = nil;
NSLog(#"pin color0:%#",m_pinColor);
pinView = (MKPinAnnotationView *)[map_View dequeueReusableAnnotationViewWithIdentifier:identifier];
if (pinView == nil)
{
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier] autorelease];
pinView.canShowCallout = YES;
pinView.animatesDrop = YES;
/*
if([m_pinColor isEqualToString:#"RED"]) {
NSLog(#"pin color1:%#",m_pinColor);
[pinView setPinColor:MKPinAnnotationColorPurple];
}
else if([m_pinColor isEqualToString:#"GREEN"]){
NSLog(#"pin color2:%#",m_pinColor);
[pinView setPinColor:MKPinAnnotationColorGreen];
}
else if([m_pinColor isEqualToString:#"BLUE"]){
NSLog(#"pin color3:%#",m_pinColor);
[pinView setPinColor:MKPinAnnotationColorRed];
}*/
}
if([m_pinColor isEqualToString:#"RED"]) {
NSLog(#"pin color1:%#",m_pinColor);
[pinView setPinColor:MKPinAnnotationColorRed];
}
else if([m_pinColor isEqualToString:#"GREEN"]){
NSLog(#"pin color2:%#",m_pinColor);
[pinView setPinColor:MKPinAnnotationColorGreen];
}
else if([m_pinColor isEqualToString:#"BLUE"]){
NSLog(#"pin color3:%#",m_pinColor);
[pinView setPinColor:MKPinAnnotationColorPurple];
}
return pinView;
//[pinView release];
}
I am also using different color pins on Map. I am using the below code. I am able to see 3 different color pins. I am working on iOS6, so my suggestion is test this code on iOS6.
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{ static NSString *identifier = #"myPin";
MKPinAnnotationView *pinView = nil;
pinView = (MKPinAnnotationView *)[map_View dequeueReusableAnnotationViewWithIdentifier:identifier];
if (pinView == nil)
{
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier] autorelease];
pinView.canShowCallout = YES;
pinView.animatesDrop = YES;
}
if([m_pinColor isEqualToString:#"Red"]) {
[pinView setPinColor:MKPinAnnotationColorRed];
}
else if([m_pinColor isEqualToString:#"Green"]){
[pinView setPinColor:MKPinAnnotationColorGreen];
}
else if([m_pinColor isEqualToString:#"Purple"]){
[pinView setPinColor:MKPinAnnotationColorPurple];
}
return pinView;
}
Place the following code outside the if statement. Otherwise when the pin is reused, the following code will not be called.
if([m_pinColor isEqualToString:#"RED"]) {
NSLog(#"pin color1:%#",m_pinColor);
[pinView setPinColor:MKPinAnnotationColorPurple];
}
else if([m_pinColor isEqualToString:#"GREEN"]){
NSLog(#"pin color2:%#",m_pinColor);
[pinView setPinColor:MKPinAnnotationColorGreen];
}
else if([m_pinColor isEqualToString:#"BLUE"]){
NSLog(#"pin color3:%#",m_pinColor);
[pinView setPinColor:MKPinAnnotationColorRed];
}

iOS MapKit custom pins

How do I show images instead of pins in the map. So far I can only add pins on tap. A sample code of the .m would extremely help since i'm still new to iOS programming.
#pragma mark -
#pragma mark MKMapView delegate
- (MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
static NSString* AnnotationIdentifier = #"AnnotationIdentifier";
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];
if(annotationView)
return annotationView;
else
{
MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:AnnotationIdentifier] autorelease];
annotationView.canShowCallout = YES;
annotationView.image = [UIImage imageNamed:#"someImage.png"];
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self action:#selector(writeSomething:) forControlEvents:UIControlEventTouchUpInside];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
annotationView.rightCalloutAccessoryView = rightButton;
annotationView.canShowCallout = YES;
annotationView.draggable = YES;
return annotationView;
}
return nil;
}
EDIT:
I could explain to you all about the MKAnnotationView, but I think you will find the documentation provided by Apple to be a far better explanation than from any other source. Check the overview section in the link.
https://developer.apple.com/documentation/mapkit/mkannotationview
Go to organizer of Xcode and then go to documentation and search weatherMap it shows example for map with including images at annotation.
#pragma mark -
#pragma mark MKMapView delegate
-(void)addAllPinsOnMapView
{
MKCoordinateRegion region = mapViewOffer.region;
region.center = CLLocationCoordinate2DMake(12.9752297537231, 80.2313079833984);
region.span.longitudeDelta= 0.1f;
region.span.latitudeDelta= 0.1f;
[mapViewOffer setRegion:region animated:YES];
mapViewOffer.delegate=self;
arrMapPin=[[NSMutableArray alloc] init];
NSArray *name=[[NSArray alloc]initWithObjects:
#"Title1",
#"Title2",
#"Title3", nil];
NSMutableArray *arrCoordinateStr = [[NSMutableArray alloc] initWithCapacity:name.count];
[arrCoordinateStr addObject:#"12.970760345459,80.2190093994141"];
[arrCoordinateStr addObject:#"12.9752297537231,80.2313079833984"];
[arrCoordinateStr addObject:#"12.9788103103638,80.2412414550781"];
for(int i = 0; i < name.count; i++)
{
NSArray *components = [[arrCoordinateStr objectAtIndex:i] componentsSeparatedByString:#","];
double latitude = [components[0] doubleValue];
double longitude = [components[1] doubleValue];
MKPointAnnotation *mapPin = [[MKPointAnnotation alloc] init];
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(latitude, longitude);
mapPin.title = [name objectAtIndex:i];
mapPin.coordinate = coordinate;
[mapViewOffer addAnnotation:mapPin];
}
}
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:
(MKAnnotationView *)view
{
NSLog(#"%#",view.annotation.title);
NSLog(#"%f",view.annotation.coordinate.latitude);
NSLog(#"%f",view.annotation.coordinate.longitude);
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(calloutTapped:)];
[view addGestureRecognizer:tapGesture];
}
-(void)calloutTapped:(UITapGestureRecognizer *) sender
{
NSLog(#"Callout was tapped");
MKAnnotationView *view = (MKAnnotationView*)sender.view;
id <MKAnnotation> annotation = [view annotation];
if ([annotation isKindOfClass:[MKPointAnnotation class]])
{
//[self performSegueWithIdentifier:#"annotationDetailSegue" sender:annotation];
OfferDetailsViewController *objOfferDetailsViewController = [[OfferDetailsViewController alloc]init];
[self.navigationController pushViewController:objOfferDetailsViewController animated:YES];
}
}
- (MKAnnotationView *)mapView:(MKMapView *)theMapView
viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView *pinView = nil;
static NSString *defaultPinID = #"annotationViewID";
pinView = (MKAnnotationView *)[mapViewOffer dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( pinView == nil ){
pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID];
}
pinView.canShowCallout = YES;
pinView.image = [UIImage imageNamed:#"placeholder"];
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[infoButton addTarget:self action:#selector(infoButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView = infoButton;
return pinView;
}

Resources