iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – Waze不加载Swift的导航大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我将Waze集成到我的 Swift应用程序中,但当我点击按钮时,Waze打开但导航没有任何反应.我很高兴看到应用程序,而不是启动导航.

这是代码

@IBACtion func openWazeAction(_ sender: Any) {
    // open waze
    if UIApplication.shared.canOpenURL(URL(String: "waze://")!) {
        let urlStr = String(format: "waze://ul?ll=%f,%f&navigate=yes",(SELEctedBorne?.LOCATIOn?.X)!,(SELEctedBorne?.LOCATIOn?.y)!)

        print(urlStr)

        UIApplication.shared.open(URL(String: urlStr)!)
    } else {
        UIApplication.shared.open(URL(String: "http://itunes.apple.com/us/app/id323229106")!)
    }
}

print(urlStr)返回正确的URL:waze:// ul?ll = 48.792914,2.366290& navigate = yes,但Waze应用程序中没有任何反应.

(我把LSApplicationQueriesscheR_987_11845@es放在Info.plist文件中.)

这有什么不对?

解决方法

解决了这个问题. Waze documentation提供了错误的信息,因为他们的iOS示例没有按原样打开Waze应用程序.它在移动设备上打开Safari,然后我们需要点击链接打开Waze.

正确的链接是:

waze://?ll={latitudE},{longitudE}&navigate=yes

我需要删除URL中的ul.

迅速

func navigateTo(latitude: Double,longitude: DoublE) {
    if UIApplication.shared.canOpenURL(URL(String: "waze://")!) {
        // Waze is installed. Launch Waze and start navigation
        let urlStr = String(format: "waze://?ll=%f,latitude,longitudE)
        UIApplication.shared.open(URL(String: urlStr)!)
    } else {
        // Waze is not installed. Launch AppStore to install Waze app
        UIApplication.shared.open(URL(String: "http://itunes.apple.com/us/app/id323229106")!)
    }
}

Objective-C的

(void) navigateToLatitude:(doublE)latitude longitude:(doublE)longitude
{
  if ([[UIApplication sharedApplication]
    canOpenURL:[NSURL URLWithString:@"waze://"]]) {
      // Waze is installed. Launch Waze and start navigation
      NSString *urlStr =
        [NSString StringWithFormat:@"waze://?ll=%f,longitude];
      [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
  } else {
    // Waze is not installed. Launch AppStore to install Waze app
    [[UIApplication sharedApplication] openURL:[NSURL
      URLWithString:@"http://itunes.apple.com/us/app/id323229106"]];
  }
}

大佬总结

以上是大佬教程为你收集整理的ios – Waze不加载Swift的导航全部内容,希望文章能够帮你解决ios – Waze不加载Swift的导航所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。