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 7031425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:48:06+00:00 2026-05-28T00:48:06+00:00

I need some help with an app i’m making using MapKit I’m struggling with

  • 0

I need some help with an app i’m making using MapKit

I’m struggling with the didUpdateUserLocation: – it keeps randomly crashing the app. When I comment out all of the code it works perfectly but this isn’t a suitable situation. I’ve been fiddling around with it all but still no real success.

Here’s my code

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
    NSLog(@"update loc");
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 250.0, 250.0);//MKCoordinateRegionMake(userLocation.coordinate, mapView.region.span);
    if (first) {
        region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 250.0, 250.0);
        first = false;
    }
    if (!CLLocationCoordinate2DIsValid(userLocation.coordinate)) {
        //do nothing, invalid regions
        NSLog(@"co-ord fail");
    } else if (region.span.latitudeDelta <= 0.0 || region.span.longitudeDelta <= 0.0) {
        NSLog(@"invalid reg");
    } else {
        [mapView setRegion:region animated:NO];
    }
} 

The app never hits “co-ord fail” or “invalid reg” so I don’t really know what the problem is since I set the values myself.

The problem usually occurs when the nib for the Map is closed and it has dealloced the view.

I have seen some other suggestions but haven’t been confident about their work. Ideally I’d like to use mapView.region.span so to maintain the zoom levels

Many Thanks,
James

  • 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-05-28T00:48:07+00:00Added an answer on May 28, 2026 at 12:48 am

    The problem usually occurs when the nib for the Map is closed and it
    has dealloced the view.

       [mapView setRegion:region animated:NO];
    

    Well isn’t that your problem then?

    This is why we have dependency inversion patterns like Observer/Listener.

    Instead of fiddling around with the view directly with your CLLocationManager delegate, use NSNotification to alert subscribing views (such as your MapView) that it should update. If the MapView has been dealloced it won’t do anything.

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

Sidebar

Related Questions

I am developing a WPF app using MVVM and need some help. for the
need ask you about some help. I have web app running in Net 2.0.
Need some help assigning a mouseover event to display some icons that start out
I need some help from the shell-script gurus out there. I have a .txt
I m new to iphone app development and i need some help. I have
I'm creating an Android app utilising OpenGL ES, and need some help with the
I need some help in using the NSURLCache to download a simple file. It
I need some help on using this pre-historic application: hyperterminal. I need to send
I need some help implementing a custom role provider in a asp.net mvc app.
I need some help. In my android app I have a ViewFlipper that contains

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.