Open maps with specific address iOS 7

后端 未结 5 1099
半阙折子戏
半阙折子戏 2021-02-19 04:14

I am trying to make my application open the apple maps application and have the address be pulled up. I tried this :

- (IBAction)openInMaps:(id)sender {
    NSS         


        
5条回答
  •  失恋的感觉
    2021-02-19 04:28

    Swift 3 version:

    let baseUrl: String = "http://maps.apple.com/?q="
    let encodedName = "yourAddress".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
    let finalUrl = baseUrl + encodedName
    if let url = URL(string: finalUrl)
        {
        UIApplication.shared.open(url, options: [:], completionHandler: nil)
        }
    

提交回复
热议问题