15
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iOS7でカスタムURLスキームでMapアプリに遷移する。

Posted at

UIActivityViewControllerなどで、Mapアプリに遷移したいときにiOS7から方式が変わったのでメモ。
参考リンク
https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html
http://ascii.jp/elem/000/000/852/852280/index-2.html

サンプルコードはこんな感じ

NSString* q = @"http://maps.apple.com/maps?q='渋谷駅'";
NSURL* url = [NSURL URLWithString:[q stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
  [[UIApplication sharedApplication] openURL:url];

いろいろオプションはあるのですが、URLに日本語を使うときはstringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncodingでエスケープするのを忘れずに。

15
15
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?