Open maps with specific address iOS 7

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

    You need to properly escape the spaces in the URL:

    NSString *addressString = @"http://maps.apple.com/?q=1%20Infinite%20Loop,%20Cupertino,%20CA";
    

    Edit - it seems using + instead of %20 for the spaces solves the problem.

    So to get it to work properly you must use this :

    NSString *addressString = @"http://maps.apple.com/?q=1+Infinite+Loop,+Cupertino,+CA";
    

提交回复
热议问题