iOS Development GPS location designated language return Chinese location

Source: Internet
Author: User

In iOS development, the use of positioning often encountered this headache problem: The system language in English when the return of English or pinyin, the system language is Chinese when the return to Chinese.

The following is a mandatory system to obtain the location of the location for Chinese. The scheme is online, but it is optimized to restore the system language after the inverse geocoding is complete, avoiding some extreme cases of non-effective issues.

measurement is feasible. Please leave a message if you have questions.

`

-(void) Locationmanager: (Cllocationmanager *) Manager didupdatetolocation: (cllocation *) newlocation fromlocation: (    Cllocation *) oldlocation{//Get latitude and longitude NSLog (@ "Latitude:%f", newLocation.coordinate.latitude);    NSLog (@ "Longitude:%f", newLocation.coordinate.longitude);    Stop location update [manager Stopupdatinglocation]; Save the current language of the Device (English, French,,,) nsmutablearray *userdefaultlanguages = [[Nsuserdefaults standarduserdefaults] Objectfo    rkey:@ "Applelanguages"]; Force into Simplified Chinese [[nsuserdefaults standarduserdefaults] Setobject:[nsarray arraywithobjects:@ "Zh-hans", Nil] forKey:@ "Ap    Plelanguages "];    Inverse geocoding Clgeocoder * GeoCoder = [[Clgeocoder alloc] init]; [GeoCoder reversegeocodelocation:newlocation completionhandler:^ (Nsarray *placemarks, Nserror *error) {if (!error) {for (Clplacemark * Placemark in Placemarks) {nsstring *cityname = [Placema                RK locality];            NSLog (@ "cityname==="%@ ", cityname);//You can see the output as Chinese break;  }      }//Restore device's language [[Nsuserdefaults standarduserdefaults] setobject:userdefaultlanguages forkey:@ "Apple    Languages "]; }];}

`

iOS Development GPS location designated language return Chinese location

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.