我有这个代码用于我的iOS应用程序:
NSString *location = [[NSString alloc] initWithFormat:@"%@,%@",[self.campus campusStreetAddress],[self.campus campusCityStateZip]]; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:location completionHandler:^(NSArray* placemarks,NSError* error){ if (placemarks && placemarks.count > 0) { CLPlacemark *topResult = [placemarks objectAtIndex:0]; MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:topResult]; MKCoordinateRegion region = self.campusMap.region; region.center = placemark.region.center; //DEPRECATED iOS 7 region.span.longitudeDelta /= 1500; region.span.latitudeDelta /= 1500; [self.campusMap setRegion:region animated:NO]; [self.campusMap addAnnotation:placemark]; } } ];
但是,当我将我的应用程序升级到iOS 7时,不推荐使用placemark.region.center.我应该使用替代品吗?这甚至是在视图中创建地图的正确方法吗?
谢谢!!
解决方法
试试这个:
region.center = [(CLCircularRegion *)placemark.region center];