iOS 代码块在程序中只执行一次

 //开启定位的同时展示用户可行驶范围
    static dispatch_once_t disOnce;
    dispatch_once(&disOnce,  ^ {
        //根据电量判断展示的圆的半径
        CGFloat radius = 1500.0f;
        _circle = [MACircle circleWithCenterCoordinate:CLLocationCoordinate2DMake(self.mapView.userLocation.location.coordinate.latitude, self.mapView.userLocation.location.coordinate.longitude) radius:radius];

        //根据半径判断缩放级别
        [_mapView setZoomLevel:[self zoomlevelAccordingRadius:radius] animated:YES];
        //在地图上添加圆
        [_mapView addOverlay: _circle];
    });

你可能感兴趣的:(ios)