我正在使用以下 API:
[[UIApplication sharedApplication] openURL: options: completionHandler: ];
openURL 的引數由以下示例格式字串生成:
@"baidumap://map/direction?origin=latlng:%f,%f | name:我的位置&destination=latlng:%f,%f|name:資源&mode=driving"
該應用程式在運行時運行流暢,但無法呼叫 baidumap。
已將匿名功能附加到 completionHandler :
^(BOOL 成功) { if (success) NSLog(@"呼叫成功 = 1"); else NSLog(@"呼叫成功= 0"); }
通過“BOOL 成功”傳入的引數始終為 0。
我懷疑問題來自格式字串。
希望熟悉百度地圖API的人能給我一些幫助。
uj5u.com熱心網友回復:
如 baidumap 網站所述,您需要進行一些轉義:
NSString *urlString = [[NSString stringWithFormat:@"baidumap://map/direction?origin=latlng:%f,%f|name:我的位置&destination=latlng:%f,%f|name:終點&mode=driving",currentLatitude, currentLongitude,_shopLat,_shopLon] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;
并且還提供源和目的地的地理坐標
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/364959.html
