用户接单并等待计费状态,关闭应用再进入应用自动进入等待结束计费页面,有低概率出现地图加载失败地图为黑色或四方格,进入其它页面后再次进入该页面地图显示正常。
由于接单页面图层超多,并且还启动了长连接线程,所以可能接单地图页面在显示时,地图可能没有初始化完毕。
修改方案,对地图的唯一实例在应用启动时就初始画地图,进入接单页面时就直接从地图唯一实例中取就可以了。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
FLDDLogDebug(@"函数");
launchedFlag = NO;
[[SingleAsyncSocket sharedInstance] initData];
.
.
.
}
-(void)initData
{
FLDDLogDebug(@"函数");
//通过判断是否生成管道来防止重复初始化
if(nil == self.endWaitPipe)
{
//fir
[FIR handleCrashWithKey:GENERALKEY];
//友盟分享
[UMSocialData setAppKey:MUMENGKEY];
//友盟统计
[MobClick startWithAppkey:MUMENGKEY reportPolicy:BATCH channelId:@"web"];
[SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
//地图
[MAMapServices sharedServices].apiKey= MAMAPKEY;
[AMapNaviServices sharedServices].apiKey =MAMAPKEY;
[AMapSearchServices sharedServices].apiKey = MAMAPKEY;
NSString *initString = [[NSString alloc] initWithFormat:@"appid=%@",IFLYKEY];
[IFlySpeechUtility createUtility:initString];
[[Singleton sharedInstance] setMAMapViewInstance:[[MAMapView alloc] initWithFrame:CGRectMake(0, 0, kControlWidth, kControlHeight)]];
self.endWaitPipe = [NSPipe pipe];
}
}
-(void)initMap
{
MAMapView *namapView = (MAMapView *)([[Singleton sharedInstance] getMAMapViewInstance]);
if(nil == namapView)
{
_mapView = [[MAMapView alloc] initWithFrame:CGRectMake(0, 0, kControlWidth, kControlHeight)];
[[Singleton sharedInstance] setMAMapViewInstance:_mapView];
}
else
{
CGRect newRect = CGRectMake(0, 0, kControlWidth, kControlHeight);
namapView.frame = newRect;
_mapView = namapView;
}
_mapView.delegate = self;
[self.view addSubview:_mapView];
[self.view sendSubviewToBack:_mapView];
[self initAMapProperty];
//定位
_mapView.showsUserLocation = YES;
}
地图唯一实例见文章:
http://blog.csdn.net/jia12216/article/details/49276155