【问题标题】:Send user location coordinates to SMS.app as an googleMaps-link将用户位置坐标作为 googleMaps 链接发送到 SMS.app
【发布时间】:2010-12-23 20:01:13
【问题描述】:

我想将我的位置坐标作为 Google 地图链接 (http://maps.google.com/?saddr=%1.6f,%1.6f) 作为 SMS 发送,但我无法让它工作。 .. 我应该怎么做才能使 GoogleMaps 链接因我的位置而异??

MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];

        controller.body = @"This is my location http://maps.google.com/?saddr=%1.6f,%1.6f";

    NSString *googleMaps = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f", location.latitude, location.longitude];

    controller.recipients = [NSArray arrayWithObjects:nil];
            controller.messageComposeDelegate = self;
            [self presentModalViewController:controller animated:YES];  
            }
    }

有什么想法吗?真的很感谢一个答案!!!!

谢谢你,节日快乐!

【问题讨论】:

  • 这段代码有什么问题?
  • 当我尝试发送链接时,链接没有发生任何事情...我想让它更改 GoogleMaps 链接到我当前的位置...。
  • 你创建的字符串的输出是什么?

标签: iphone google-maps sms mapkit messageui


【解决方案1】:

你不应该:

controller.body = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f", location.latitude, location.longitude];

您正在对正文进行硬编码,然后创建一个不相关的字符串,该字符串可能格式正确,并且从未对其进行任何操作。

【讨论】:

  • 你需要熟悉nsstring,你会到处使用它来学习它。
【解决方案2】:

你需要做 location.coordinate.latitude, location.coordinate.longitude 假设 location 是一个 cllocation 对象。

【讨论】:

  • 这是一个 CLLocationCoordinate2D... 所以我不能把它作为 location.coordinate.longitude 和 location.coordinate.latitude !
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多