0

I am trying to make a button that will locate my current location and zoom in. I did try the program and the error show up. Here is the program.

viewController.m

@interface ViewController : UIViewController {

IBOutlet MKMapView *mapview;
}

-(IBAction)findmylocation:(id)sender;

viewController.m

@implementation ViewController

-(IBAction)findmylocation:(id)sender {

mapview.showsUserLocation = YES;
mapview.delegate = self;  <-------[WARNING]
[mapview setUserTrackingMode:MKUserTrackingModeFollow animated:YES];

}

The warning error show up on "mapview.delegate = self;" and when i run the application I can't click the button to locate my self. If i click it it will say

.... Application Trying to start MapKit location updates without prompting for location authorization. 
Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.

This is what warning said on "mapview.delegate = self;" line

Assigning to 'id<MKMapViewDelegate>' from incompatible type 'ViewController *const_strong'

I don't know what is wrong?

thunpisit
  • 117
  • 1
  • 4
  • 12
  • Must call -[CLLocationManager requestWhenInUseAuthorization] this is what you have to do. – Avis Oct 29 '14 at 18:47
  • possible duplicate of [Xcode 6 GM - CLLocationManager](http://stackoverflow.com/questions/25844430/xcode-6-gm-cllocationmanager) – Paulw11 Oct 29 '14 at 19:22
  • You get the warning when assigning your delegate because your Viewacontroller class definition doesn't include the CLLocationManagerDelegate protocol. – Paulw11 Oct 29 '14 at 19:23

0 Answers0