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

  • Home
  • SEARCH
  • 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 8972753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:17:34+00:00 2026-06-15T18:17:34+00:00

I have a MKMapView in a UITableViewCell with user interaction disabled. When I scroll

  • 0

I have a MKMapView in a UITableViewCell with user interaction disabled. When I scroll the UITableViewCell it refreshes all of the MKMapViews.

I’ve read the other answers on here, one says to not to use dequeueReusableCellWithIdentifier (I’m not) and the other says to dealloc the mapView (I’m using ARC). I don’t want to use images.

What should I do to prevent the MKMapView from reloading when I scroll my scrollview?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    //UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ANFeedCell"];
    ANFeedTableViewCell *cell = nil;
    if (cell == nil) {
        // Load the top-level objects from the custom cell XIB.
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ANFeedTableViewCell" owner:self options:nil];
        // Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
        cell = [topLevelObjects objectAtIndex:0];

        MKMapView *mapView = (MKMapView*)[cell viewWithTag:2];

        //Takes a center point and a span in miles (converted from meters using above method)        
        CLLocationCoordinate2D startCoord = CLLocationCoordinate2DMake(37.766997, -122.422032);
        MKCoordinateRegion adjustedRegion = [mapView regionThatFits:MKCoordinateRegionMakeWithDistance(startCoord, MilesToMeters(0.5f), MilesToMeters(0.5f))];
        [mapView setRegion:adjustedRegion animated:YES];


    }
return cell;
}
  • 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-15T18:17:35+00:00Added an answer on June 15, 2026 at 6:17 pm

    The problem is you are initializing NEW cells for every table cell.
    So your MapView get’s reset every time.

    This will also lead to memory problems, as a few scrolls up & down the table, will drain your phone’s memory.

    Stick to reusable cells, but configure the mapview region every time for the cells.

    Here is a good example to get your started:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    
        static NSString *CustomCellIdentifier = @"MyCustomTableCell";
        ANFeedTableViewCell *cell = (ANFeedTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier];
    
        if (cell == nil) {
            NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ANFeedTableViewCell"
                                                         owner:self options:nil];
            for (id oneObject in nib)
                if ([oneObject isKindOfClass:[CustomCell class]])
                    cell = (ANFeedTableViewCell *)oneObject;
        }
    
    
    
        MKMapView *mapView = (MKMapView*)[cell viewWithTag:2];
    
        //Takes a center point and a span in miles (converted from meters using above method)
        CLLocationCoordinate2D startCoord = CLLocationCoordinate2DMake(37.766997, -122.422032);
        MKCoordinateRegion adjustedRegion = [mapView regionThatFits:MKCoordinateRegionMakeWithDistance(startCoord, MilesToMeters(0.5f), MilesToMeters(0.5f))];
        [mapView setRegion:adjustedRegion animated:YES];
    
        return cell;
    }
    

    What is different in this code, is that the mapview is configured each time a cell is displayed, not only when it’s initialized.
    Of Course you should change the code to accept the coordinates dynamically from a datasource (i.e. a NSArray).

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

Sidebar

Related Questions

I have an MKMapView which allows the user to scroll the map around. Later,
How can I have my MKMapView follow my user around until they scroll, and
I have a MKMapView with scrolling and userInteraction disabled within a UITableViewCell . The
I have a MKMapView & I use it to display user's current location. It
I have an app which is providing a zoomable MKMapView to the user. I
I have a MKMapView and in the Map View Show User Location is set.
I have an MKMapView that's supposed to track the user's location using a custom
I have an MKMapView with an MKUserTrackingBarButtonItem . The user's current location should only
I have a MKMapView in one of my views with some annotations on it.
I have a custom UITableViewCell set up with a MKMapView set up within the

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.