检查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及更高版本中返回错误。我们必须从“谷歌地图:/”中删除“/”。