4

I have a TabView, and one of my tabs contains a mapView. When I load the tab with the mapView for some reason regionDidChangeAnimated is called twice. I've put break points in every other function and disabled them all from running, so it's literally just pulling up a blank map. Nonetheless, regionDidChangeAnimated is being called twice. Any ideas why that might be?

Here's the code:

SecondViewController.h:

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface SecondViewController : UIViewController<MKMapViewDelegate> 
{IBOutlet MKMapView *mapView;}
@end

SecondViewController.m

#import "SecondViewController.h"
@implementation SecondViewController

- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
    //[self showTowers];
    NSLog(@"regionDidChangeAnimated");
}

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

- (void)dealloc {
    [super dealloc];
}
Sina
  • 398
  • 1
  • 3
  • 10

1 Answers1

1

I'm pretty sure this happens because of automatic view resizing. Try implementing - (void)viewWillLayoutSubviews in you view controller and log how often this is called.

Klaas
  • 22,394
  • 11
  • 96
  • 107