MkMapView regionDidChangeAnalyzed delegate runs twice when loading tabs

I have a TabView and one of my tabs contains mapView. When I load a tab with mapView, for some reason regionDidChangeAnimated is called twice. I set breakpoints in every other function and disconnected them from starting, so it literally just pulls up an empty map. However, regionDidChangeAnimated is called twice. Any ideas why this could be?

Here is 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];
}
+3
source share
1 answer

I am sure this is due to automatic resizing. Try to implement - (void)viewWillLayoutSubviewsin your view the controller and the log, how often this is called.

0

Source: https://habr.com/ru/post/1794639/


All Articles