mkMapView's regionDidChangeAnimated delegate fired twice on tab load
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];
}
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.
精彩评论