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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:20:55+00:00 2026-06-14T10:20:55+00:00

Trying to learn my way around MKMapView, but I’ve followed several tutorials and I

  • 0

Trying to learn my way around MKMapView, but I’ve followed several tutorials and I can’t seem to get it to zoom into my defined location, instead it just loads to a whole map view centered around the Atlantic ocean. I’m guessing something has changed in iOS6 that means the tutorials I am using no longer work? (The tutorials are iOS3-iOS5).

I’ve made a ViewController in Interface Builder, given it the custom class of MapViewController. I then dragged on MKMapView and using the Assistant Editor put this into MapViewController.h

MapViewController.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface MapViewController : UIViewController
@property (weak, nonatomic) IBOutlet MKMapView *myMapView;

@end

MapViewController.m

#import "MapViewController.h"

#define CLS_LATITUDE 54.85477
#define CLS_LONGITUDE -1.57371
#define SPAN 0.10f;

@interface MapViewController ()

@end

@implementation MapViewController
@synthesize myMapView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

 - (void)viewDidLoad
{
    [super viewDidLoad];
    MKCoordinateRegion myRegion;
    CLLocationCoordinate2D center;
    center.latitude = CLS_LATITUDE;
    center.longitude = CLS_LONGITUDE;
    MKCoordinateSpan mySpan;
    mySpan.latitudeDelta = SPAN;
    mySpan.longitudeDelta = SPAN;
    myRegion.center = center;
    myRegion.span = mySpan;
    [myMapView setRegion:myRegion animated:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 @end
  • 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-14T10:20:56+00:00Added an answer on June 14, 2026 at 10:20 am

    The code for the region looks correct. Are you sure you have linked up the myMapView outlet in interface builder?

    enter image description here

    If you click and hold on the “File’s Owner” object on the left, then hold Ctrl and drag from the File’s Owner to the map view in the interface, when you let go of the mouse button you should get the option to set the outlet to myMapView. You can then see the link in the Connections inspector as shown on the right.

    EDIT:

    OK, so it appears that, as you are using Autolayout, the map view’s frame has not been set by the time viewDidLoad gets called. I suggest you move it to - (void)viewWillLayoutSubviews. For example:

    - (void)viewWillLayoutSubviews {
        [super viewWillLayoutSubviews];
        [self setLocation];
    }
    
    -(void)setLocation {
        // Set region etc...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to learn qmake, but can't find a native way to create .pri
Trying to learn Sencha Touch 2 and I can't seem to find out how
Im trying to fool around with a rails application to learn the proper way
I'm trying to learn my way around some Mirth code. I keep seeing things
I'm trying to learn pygame, And I found the best way to have the
I am trying to learn network programming with C++, the portable way(not sticking to
I am trying to learn C++ fstream, ifstream, ofstream. On Half way through my
I'm just messing around trying to learn a little bit about parallel computing. If
Am trying to learn Python the Atlantic way and am stuck on Project Euler
If I am messing around with XCode and trying to learn Objective-C, does it

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.