關(guān)于高德地圖的MAMapView踩坑
在使用高德地圖的MAMapView地圖的時候碰到無法設(shè)置size的情況:
self.mapView = [[MAMapView alloc] initWithSize:CGSizeMake(100, 100)];
self.mapView.delegate = self;
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.mapView];
地圖會自動適應(yīng)self.view,后來才發(fā)現(xiàn)MAMapView會自適應(yīng)SuperView,所以在需要自己再加一層View:
UIView *mapContentView = [[UIView alloc] initWithFrame:CGRectMake(15.f, 10.f, 300, 300)];
[self.view addSubview:mapContentView];
self.mapView = [[MAMapView alloc] initWithSize:mapContentView.size];
self.mapView.delegate = self;
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[mapContentView addSubview:self.mapView];