我有這樣的代碼在我的文件,的MKMapView馬託 'didUpdateUserLocation' 不是要求
@synthesize myLocation;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.locationManager = [[CLLocationManager alloc] init];
myLocation.delegate = self;
[self.locationManager requestWhenInUseAuthorization];
[myLocation setShowsUserLocation: YES];
}
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 800, 800);
[self.myLocation setRegion:[self.myLocation regionThatFits:region] animated:YES];
}
但是,方法didUpdateUserLocation不是要求。
我已經在應用程序中添加了必需的框架。
我在info.plist文件中添加了所有內容。但它仍然沒有呼喚。
這是我的.h文件中,
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
@interface MapView : UIViewController <MKMapViewDelegate, CLLocationManagerDelegate>
@property (weak, nonatomic) IBOutlet MKMapView *myLocation;
@property(nonatomic, retain) CLLocationManager *locationManager;
@end
您是否添加了委託? (CLLocationManagerDelegate)請發佈你的類實例。 – Andrei
'MKMapView'對象在哪裏?在哪裏設置代表? – Larme
添加了所有問題。 @Larme – KAR