Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For displaying map here is an example code.</p> <p>First import MKMapKit and CoreLocation framework in your .h file.</p> <pre><code>#import &lt;MapKit/MapKit.h&gt; #import &lt;CoreLocation/CoreLocation.h&gt; </code></pre> <p>Add MKMapKit and CoreLocation Delegate in .h file</p> <pre><code>@interface MapViewController : UIViewController &lt;MKMapViewDelegate, CLLocationManagerDelegate&gt; CGPoint gameMapCenter = CGPointMake([[UIScreen mainScreen] bounds].size.width / 2, [[UIScreen mainScreen] bounds].size.height / 2); gameMapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 640, 620)]; [gameMapView setCenter:gameMapCenter]; [gameMapView setMapType:MKMapTypeStandard]; [gameMapView setDelegate:self]; [self.view addSubview:gameMapView]; [gameMapView setShowsUserLocation:YES]; </code></pre> <p>Use <code>CLLocationManager</code> for fetching user location.</p> <p>Declare an instance of CLLocationManager</p> <pre><code>CLLocationManager *locationManager; </code></pre> <p>In <code>ViewDidLoad</code></p> <pre><code>locationManager = [[CLLocationManager alloc] init]; [locationManager setDelegate:self]; [locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [locationManager setDistanceFilter:kCLDistanceFilterNone]; [locationManger startUpdatingLocation]; </code></pre> <p><code>startUpdatingLocation</code> Method Implementation:</p> <pre><code>(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { //Your Stuff } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload