iOS7 iOS8 Positioning compatibility Issue Solution

Source: Internet
Author: User

Recently developed app positioning function in the iOS8 can be normal operation, but to the iOS7 machine can not run normally, because the two systems are not the same positioning, for different systems need to do some processing. Here are some of my handling methods.

@property(nonatomic,Strong) Cllocationmanager * locmgr;-(Cllocationmanager *) locmgr{if(_locmgr = =Nil) { Self. Locmgr= [[Cllocationmanager alloc]init]; Self. Locmgr. Delegate= Self; }return_locmgr;} - (void) init{if([Cllocationmanager locationservicesenabled]) {//ios8 and above need to be set, pop-up is allowed to use location hints        if(Ios8_or_later) {            [ Self. LocmgrRequestalwaysauthorization]; }        [ Self. LocmgrStartupdatinglocation]; Self. Locmgr. Distancefilter= Kcldistancefilternone; Self. Locmgr. Desiredaccuracy=kcllocationaccuracybestfornavigation; }Else{//Alert the user to open the positioning switchUialertview * alert = [[Uialertview alloc]initwithtitle:@"Prompt?" "message:@"Kiss!" You haven't turned on location services yet! Please go to Settings to open Location Services! "Delegate Selfcancelbuttontitle:@"Cancel"otherbuttontitles:@"OK",Nil];    [Alert show]; }}#pragma mark-cllocationmanagerdelegate- (void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (Nsarray*) locations{the//locations array contains a Cllocation object, and a Cllocation object represents a positionCllocation *loc = [locations Firstobject];//Dimension: Loc.coordinate.latitude    //Longitude: Loc.coordinate.longitude    NSLog(@"Latitude =%f, longitude =%f", loc. Coordinate. Latitude, loc. Coordinate. Longitude);NSLog(@"%d", Locations. Count);    Location * Loca = [[Location alloc] init]; Loca. Lat= [NSStringstringwithformat:@"%f", loc. Coordinate. Latitude]; Loca. LNG= [NSStringstringwithformat:@"%f", loc. Coordinate. Longitude]; Self. Defaultshoplistmodel. Filter. location= Loca; Self. Hotshoplistmodel. Filter. location= Loca; Self. Nearshoplistmodel. Filter. location= Loca; [ SelfUpdatedatas]; [ SelfUpdateviews];//Stop update location (if the location service does not need to be updated in real-time, you should stop updating)[ Self. LocmgrStopupdatinglocation];}

Of course, you'll need to set up some in the engineering catalog

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

iOS7 iOS8 Positioning compatibility Issue Solution

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.