IOS 8 using the system to bring your own navigation

Source: Internet
Author: User

  viewcontroller.m//  app Self-guided////  created by wup on 15/ 5/23.//  copyright  (c)  2015 year  apple. all rights reserved.//#import   "ViewController.h" #import  <MapKit/MapKit.h> @interface  ViewController  () @property   (Nonatomic,strong)   CLGeocoder *geo; @end @implementation viewcontroller-  (void) Viewdidload {    [super viewdidload];    // do any  additional setup after loading the view, typically from a  nib.//    cllocationmanager *clmgr = [[cllocationmanager alloc]  init];//    [clmgr requestalwaysauthorization];    //     mkmapview *mv = [[mkmapview alloc] initwithframe:self.view.bounds];//     [self.view addsubview:mv];    [self.geo  geocodeaddressstring:@ "Lijiang"   completionhandler:^ (Nsarray *placemarks, nserror *error)  {                               //get to the beginning of the mkplacemark                 mkplacemark *startplace = [[mkplacemark alloc]  initWithPlacemark:[placemarks firstObject]];                 //waiting to get to the beginning of the placemarks after getting the end of the Placemarks,block callback delay problem          [self.geo  geocodeaddressstring:@ "Beijing"  completionhandler:^ (NSArray  *placemarks, nserror *error)  {                         /**                the mkplacemark,mkplacemark  that gets to the end point is the subclass of Clplacemark.              */             mkplacemark *endplace = [[mkplacemark alloc]  initWithPlacemark:[placemarks firstObject]];                         /**               convert Mkplacemark to Mkmapitem so that it can be put into the item array               */             mkmapitem *startitem = [[mkmapitem alloc  ] initWithPlacemark:startPlace];            mkmapitem *enditem = [[ mkmapitem alloc ] initwithplacemark:endplace];                         nsarray * item = @[startitem ,enditem];                         //setting the parameters of the dictionary store navigation              nsmutabledictionary *md = [ nsmutabledictionary dictionary];             md[mklaunchoptionsdirectionsmodekey] = mklaunchoptionsdirectionsmodedriving;             md[MKLaunchOptionsMapTypeKey] = [NSNumber  Numberwithinteger:mkmaptypehybrid];                                                               /**              * calls the app with its own navigation, it needs to pass in an array and a dictionary, and put the mkmapitem,         in the array.       dictionary to put the corresponding key value                             mklaunchoptionsdirectionsmodekey    Open Navigation mode               MKLaunchOptionsMapTypeKey   Map Mode                                                    mkmaptypestandard  = 0,                                                    mkmaptypesatellite,                                                    mkmaptypehybrid                           //  Navigation mode               mklaunchoptionsdirectionsmodedriving  Drive;              MKLaunchOptionsDirectionsModeWalking  Walking;              */#warning   In fact, all the code is for the following sentence, open the system comes with a gold map and perform certain actions, The parameters inside the launchoptions specify which actions to do             [mkmapitem  openMapsWithItems:item launchOptions:md];        }];  &NBSP;&NBSP;&NBSP;}];&NBSP,} #pragma  mark -  Super lazy load-(clgeocoder *) geo{     if  (!_geo)     {        _geo =  [[CLGeocoder alloc] init];             }    return  _geo;} @end








IOS 8 using the system to bring your own navigation

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.