Mapbox show Exception and terminate when using mbtiles in ios

喜你入骨 提交于 2019-12-13 06:14:28

问题


I am using MapBox example and I have imported my mbtiles file. I am getting this error:

MB Example[8517:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSURL initFileURLWithPath:]: nil string parameter'

I have checked my mbtile file and its loading on x-code so there no problem with it.


回答1:


RMMBTilesSource is indeed using that code. You need to make sure that your OSMBright.mbtiles file is part of the project's target and being added to your bundle so that it can be pulled up as a tile source. Like any resource that you need to use in your app, it's not enough to simply be part of the Xcode project.




回答2:


The reason for the crash is clear from your question itself. reason : [NSURL initFileURLWithPath:]: nil string parameter. You are initializing NSURL without passing a nil parameter. Search for initFileURLWithPath and check wether the parameter is nil or not

 [NSURL initFileURLWithPath:] // Pass a valid path here



回答3:


Your question cannot be answered correctly in it's current format. You need to add the code related to the issue.

The issue is you are passing a nil parameter to the initFileURLWithPath method.

Possibly the mbtiles file is missing. So it'll return nil, also issue can be in the Mapbox.

Please check that you added it to the project correctly.




回答4:


Had the same error. Are you sure you copied the MapBox.bundle from the .framework into your Xcode-Project as stated here: https://www.mapbox.com/mapbox-ios-sdk/

? That fixed it for me!




回答5:


I have similar problem. Don't set Custom class field in storyboard or xib...

Example:

 RMMapboxSource *tileSource = [[RMMapboxSource alloc] initWithMapID:@"YOUR MAP ID"];
 RMMapView *map = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:tileSource ];
 [self.view addSubview:map];


来源:https://stackoverflow.com/questions/17270939/mapbox-show-exception-and-terminate-when-using-mbtiles-in-ios

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!