iOS Targeting and location information acquisition

Source: Internet
Author: User

To implement maps and navigation, it is often necessary to familiarize yourself with the positioning function and navigate through the core location framework in iOS. The Core location itself can be used alone, and the map development framework Mapkit is completely independent, but often map development is used in conjunction with the positioning framework. Positioning, geocoding (including anti-coding) features are primarily included in the core location.

positioning is a very common feature, such as some map software opened after the user allows the software to locate, then open the software will automatically lock to the current location, if the user mobile phone so the current location will also follow the change. To implement this feature, you need to use the Cllocationmanager class in core loaction . First look at some of the main methods and properties of this class:

IOS 8 also provides a more user-friendly positioning service option. The app's location service is no longer just turned off or turned on, and now the location service is enabled with three options, "never", "Use Application period" and "always". At the same time, given the power consumption issue, if an app requires that location services always be available in the background, IOS 8 will not only proactively ask you when the app is first opened, but also remind you that the app has been using the location service in the background and asks if you want to continue to allow it. In IOS7 and previous versions, if you use location services in your application as long as the Startupdatinglocation method app is called in the program, the user is asked whether or not the app is allowed to use location services. At the same time, you can tell the user what to use by configuring privacy-location usage Description during the prompt, and this configuration is optional info.plist.
However, configuration configuration items have changed in IOS8 and can be configured by nslocationalwaysusagedescription or nslocationwheninuseusagedescription to tell the user the purpose of using location services, and note that this configuration is necessary, if not configured by default, the app will not be able to use location services, open the app does not give you a hint to open location services, unless you set up the app's location services after installation. At the same time, the Requestalwaysauthorization or locationservicesenabled method needs to be requested in the application according to the configuration. As I machine has been updated to the latest iOS8.1 content is mainly for iOS8, using iOS7 friends need a little adjustment.

Below I summarize the simple implementation of the next positioning function.

Locating and retrieving location information to load two dynamic libraries Corelocation.framework and mapkit.framework a get coordinates one provides a counter-check

In the Rootviewcontroller. h file,

In the Rootviewcontroller. m file,

Button response method, when clicking on the button to start the wait bit

Proxy methods for Locationmanager

iOS Targeting and location information acquisition

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.