iOS - 从代码运行第三方导航应用程序 [英] iOS - run 3rd party navigation app from code

查看:117
本文介绍了iOS - 从代码运行第三方导航应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS新手,我想从我自己的应用程序运行导航应用程序。现在我只用这个代码:

   - (void)navigationButtonTap:(id)sender 
{
类mapItemClass = [MKMapItem类];
if(mapItemClass&& [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions :)])
{
//创建一个MKMapItem传递给地图应用程序
CLLocationCoordinate2D坐标=
CLLocationCoordinate2DMake([actualPlace.latitude doubleValue],[actualPlace.longitude doubleValue]);
MKPlacemark * placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate
addressDictionary:nil];
MKMapItem * mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
[mapItem setName:actualPlace.Name];
//将地图项传递给地图应用
[mapItem openInMapsWithLaunchOptions:nil];


$ / code $ / pre

它正在工作,我知道如何更改它启动导航后运行Apple地图。没关系,但现在我正在考虑一些第三方选项。 Google地图等其他导航应用如何? iOS用户可以将它们设置为默认并使用它们吗?我如何让用户选择启动他想要的应用程序?



我发现用于实现Google Maps的代码选项。但它与Apple地图的代码不同。我可以为所有导航应用程序使用相同的代码,然后用户决定运行哪些应用程序? 您可以启动第三方导航应用程序,然后当另一个应用符合/实现url模式时,只交出地址或地理位置。一些导航应用程序实际上会这样做

I am new to iOS and I want to run navigation app from my own app. For now I just use this code:

- (void)navigationButtonTap:(id)sender
{
    Class mapItemClass = [MKMapItem class];
    if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)])
    {
        // Create an MKMapItem to pass to the Maps app
        CLLocationCoordinate2D coordinate =
        CLLocationCoordinate2DMake([actualPlace.latitude doubleValue], [actualPlace.longitude doubleValue]);
        MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate
                                                       addressDictionary:nil];
        MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
        [mapItem setName:actualPlace.Name];
        // Pass the map item to the Maps app
        [mapItem openInMapsWithLaunchOptions:nil];
    }
}

and it's working and I know how can I change it to run Apple maps with navigation started. It's okay but now I am thinking about some 3rd party options. How it's with other navigation apps like Google maps and others? Can iOS users set them as default and use them? How can I give user options to launch app which he wants?

I found code for implementing Google Maps option. But it's different code from Apple maps. Can I have same code for all navigation apps and then user decides which to run?

解决方案

You can launch 3rd party navigation apps and hand over an address or geo location only, when the other app conforms/implements an url schema. Some navigation apps actually do that.

这篇关于iOS - 从代码运行第三方导航应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆