How to get the current location of iPhone through code?

后端 未结 7 1400
野的像风
野的像风 2020-12-30 16:53

How do you get the current location of iPhone through code? I need to track the location using GPS.

相关标签:
7条回答
  • 2020-12-30 17:56

    The real solution can be found here. Z5 Concepts iOS Development Code Snippet

    It just requires a little bit of encoding.

    - (IBAction)directions1_click:(id)sender
    {
        NSString* address = @"118 Your Address., City, State, ZIPCODE";
        NSString* currentLocation = @"Current Location";
        NSString* url = [NSStringstringWithFormat: @"http://maps.google.com/maps?saddr=%@&daddr=%@",[currentLocation stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        UIApplication *app = [UIApplicationsharedApplication];
        [app openURL: [NSURL URLWithString: url]];
    }
    
    0 讨论(0)
提交回复
热议问题