Location of map positioning before IOS8.0

Source: Internet
Author: User

The steps to locate before ios8.0 are as follows:

1. First switch our project version to 7.0

2. Import the header file in the viewcontroller.m file

#import <CoreLocation/CoreLocation.h>

3. Create location managers use lazy loading and set up proxies to comply with the protocol because the location Manager object is not a singleton so we need to define it as a member property to ensure that it is not created.

4. Achieve a small function when the user clicks on the controller's view we start to locate the user's location, so the following methods are implemented in VIEWCONTROLLER.M

5. The location manager notifies his agent when the user location is located, so we need to implement the following proxy methods to do some related business processing in this method

At this point we will select the simulator to 5s

Then run the program, the following interface will appear:

Then we click on the screen to show the following interface:

You may see the interface pop up when other apps are installed, because from IOS6, Apple has to protect the user's privacy. All actions involving user privacy require user permission.

But you will find that the message is in English, but the other app pop-up is all used by our heavenly people can understand the very friendly Chinese hints, then how do we modify it?

It's really simple. We just need to add the following fields to the Info.plist file:

Privacy-location Usage Description

For example, I filled out the following information:

This time we run the program and you will notice that the message has become something we have modified:

We click OK

This time you will see that the console will always print information:

Here we will be able to successfully achieve the location of the user positioning, but there is also a problem is that if we put the application back to the background when we can not locate the user location, how to solve this problem?

In fact, the solution is very simple, just follow my demo settings to do it:

The first step:

Step Two:

Step Three:

After setting it up, try returning the app to the background and still be able to navigate to the user's location.

All right, here we go!

Location of map positioning before IOS8.0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.