Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
检查iOS 6中是否安装了谷歌地图应用程序_Ios_Objective C_Google Maps_Cocoa Touch_Uialertview - Fatal编程技术网

检查iOS 6中是否安装了谷歌地图应用程序

检查iOS 6中是否安装了谷歌地图应用程序,ios,objective-c,google-maps,cocoa-touch,uialertview,Ios,Objective C,Google Maps,Cocoa Touch,Uialertview,我正在试图找出如何处理这段代码的结果,以查看应用程序中是否安装了谷歌地图 [[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"comgooglemaps://"]]; 我正在创建一个带有选项的UIAlertView,如果是或不是,我希望为用户提供不同的选项 如何将上述代码的结果转换为布尔值 提前感谢。结果已经是布尔值: BOOL canHandle = [[UIApplication sharedAppli

我正在试图找出如何处理这段代码的结果,以查看应用程序中是否安装了谷歌地图

[[UIApplication sharedApplication] canOpenURL:
[NSURL URLWithString:@"comgooglemaps://"]];
我正在创建一个带有选项的
UIAlertView
,如果是或不是,我希望为用户提供不同的选项

如何将上述代码的结果转换为布尔值

提前感谢。

结果已经是布尔值:

BOOL canHandle = [[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"comgooglemaps:"]];

if (canHandle) {
   // Google maps installed
} else {
   // Use Apple maps?
}
iOS 9.0的以上版本

步骤1。在应用程序信息列表的LSApplicationQueriesSchemes中添加comgooglemaps

第2步。

BOOL isGoogleMap = [[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"comgooglemaps://"]];
UIAlertView *alert;

if(isGoogleMap)
{
    alert = [[UIAlertView alloc]
             initWithTitle:@"Get Directions"
             message:@"Show Map"
             delegate:self
             cancelButtonTitle:@"Cancel"
             otherButtonTitles:@"View in Apple Maps", @"View in Google Maps", nil];
}
else
{
    alert = [[UIAlertView alloc]
             initWithTitle:@"Get Directions"
             message:@"Show Map"
             delegate:self
             cancelButtonTitle:@"Cancel"
             otherButtonTitles:@"View in Apple Maps", nil];
}
alert.tag = 1010;
[alert show];

很酷,现在说得通了-从未见过这样的情况:-)它返回false,iphone中已经有谷歌地图了ios9还有其他解决方案吗???你需要在iOS 9中调用的应用程序url方案列表中添加
comgooglemaps://
。只需将您将被调用的URL添加到应用程序
info.plist
中的
lsapplicationqueryschemes
,我已经在lsapplicationqueryschemes(plist文件)中添加了comgooglemaps://。但它仍然给出了错误的结果。谷歌地图在我的iPhone中可用,但在iOS9.0及更高版本中返回错误。我们必须从“谷歌地图:/”中删除“/”。