Open maps with specific address iOS 7

后端 未结 5 1077
半阙折子戏
半阙折子戏 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:53

    Swift 2
    
     let baseUrl : String = "http://maps.google.com/?q="
                let name : String = tableCellData[indexPath.row]
                let encodedName = "address of yours"
                name.stringByAddingPercentEncodingWithAllowedCharacters(.URLQueryAllowedCharacterSet())
                let finalUrl = baseUrl + encodedName!
    
                let url = NSURL(string: finalUrl)!
                UIApplication.sharedApplication().openURL(url)
    

提交回复
热议问题