Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9022553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:32:22+00:00 2026-06-16T05:32:22+00:00

I have an application (Xcode 4.5) which downloads images from Flicker. I have a

  • 0

I have an application (Xcode 4.5) which downloads images from Flicker. I have a mapview which drops a pin for the location of each photo. Clicking the pin reveals an annotation which shows the name of the photo and a thumbnail of its image. I made the application universal to begin with, and the iPad version works as expected. However, when I attempted to adjust the code for the iPhone version, (using the same classes as I was for iPad) the pins do not appear in the map view for the iphone. I can’t figure out what I missed and I am hoping someone can help. Here is what I did.

1) I created a new view controller in the iPhone storyboard and hooked it up to my map view controller class that is working for iPad. I added a mapView outlet and adjusted code accordingly.
2) In the tableView controller (which segues to mapView controller) I added a prepare for segue method that is supposed to update the map view in the map view controller with the annotation info.

here is the code:

// in the tableView controller

- (NSArray *)mapAnnotations
{
   NSMutableArray *annotations = [NSMutableArray arrayWithCapacity:[self.photos count]];
   for (NSDictionary *photo in self.photos) {
       [annotations addObject:[FlickrPhotoAnnotation annotationForPhoto:photo]];
   }
   return annotations;
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"iPhoneMap"]) {
           id destinationViewController = segue.destinationViewController;
                if ([destinationViewController isKindOfClass:[MapViewController class]])    
                {
                MapViewController *mapVCIphone = 
                               (MapViewController *)destinationViewController;
                    mapVCIphone.delegate = self;
                    mapVCIphone.annotations = [self mapAnnotations];
                }
    }

}

//in the mapView controller:

@property (weak, nonatomic) IBOutlet MKMapView *mapViewIphone;
@synthesize mapViewIphone = _mapViewIphone;

- (void)updateMapView
{
//if there are any current annotatons, remove them 
   //if there exists a new array of annotations, then add those to the map

if (self.splitViewController) {
    if (self.mapView.annotations) [self.mapView   
                           removeAnnotations:self.mapView.annotations];
    if (self.annotations) [self.mapView addAnnotations:self.annotations];
}   else {
        if (self.annotations) [self.mapViewIphone addAnnotations:self.annotations];
        if (self.mapViewIphone.annotations) [self.mapViewIphone 
                          removeAnnotations:self.mapViewIphone.annotations];
    }
}

- (void)setAnnotations:(NSArray *)annotations
{
   _annotations = annotations;
   [self updateMapView];
}

- (void)setMapView:(MKMapView *)mapView //iPad mapView
{
   _mapView = mapView;
   [self updateMapView];
}

- (void)setMapViewIphone:(MKMapView *)mapViewIphone
{
   _mapViewIphone = mapViewIphone;
   [self updateMapView];
}

Also in this code is the implementation of the MKMapViewDelegate protocols, which I did not include here as I did not need to change them for iPhone. Can anyone tell me what I might have missed? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:32:26+00:00Added an answer on June 16, 2026 at 5:32 am

    Here:

    if (self.splitViewController) {
        if (self.mapView.annotations) [self.mapView   
                               removeAnnotations:self.mapView.annotations];
        if (self.annotations) [self.mapView addAnnotations:self.annotations];
    }   else {
            if (self.annotations) [self.mapViewIphone addAnnotations:self.annotations];
            if (self.mapViewIphone.annotations) [self.mapViewIphone 
                              removeAnnotations:self.mapViewIphone.annotations];
        }
    }
    

    In the iPad version you are
    – REMOVING existing annotations then
    – ADDING new annotations

    In the iPhone version you are
    – ADDING new annotations then
    – REMOVING those same annotations (now existing annotations) in the next line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application (Xcode 4.5) which downloads images from Flicker. I have a
I have installed from XCode -> Preferences -> Downloads the Command Line Tools .
I have a mac os x application, which was developed in Xcode 3.1.1, now
I have an Xcode project which builds a Cocoa desktop Browser application. My Browser
I have an iPad application which has many categorized images I need to switch
I have an application (installer, actually) that was built outside of Xcode which I
I have developing an iPhone application using xcode 4 which is compatible with iOS
I have an application in XCode using the sqlite/coredata database and that has already
I have a master detail Application in xCode. In Master View Controller an Array
I have snow leopard and I'm building a cpp Application with xcode. I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.