我在Apple關注開發新的,並希望在Apple關注整合的蘋果地圖中,只是想表明我的當前位置,但我每次加載模擬器的界面我得到了屏幕像下面的時間。任何幫助可以欣賞。如何在蘋果手錶中集成蘋果地圖?
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation* loc = [locations lastObject];
CLLocationCoordinate2D myLocationCoordinate2D = loc.coordinate;
[self.demoMap setRegion:MKCoordinateRegionMake(myLocationCoordinate2D, MKCoordinateSpanMake(0.0,0.0))];//set map region
[self.demoMap addAnnotation:myLocationCoordinate2D withPinColor:WKInterfaceMapPinColorGreen];// set pin on map
[locationManager stopUpdatingLocation];
}
#pragma mark - CLLocation Manager
-(void)startTrackingCurrentLcoation:(BOOL)forTrip
{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager requestAlwaysAuthorization];
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
if (status == kCLAuthorizationStatusAuthorizedAlways || status == kCLAuthorizationStatusAuthorizedWhenInUse)
{
NSLog(@"%@ Start tracking current location", self);
[locationManager startUpdatingLocation];
}
}
-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
status = [CLLocationManager authorizationStatus];
if (status == kCLAuthorizationStatusDenied)
{
NSString *message = @"To use background location you must turn on 'Always' in the Location Services Settings";
NSLog(@"%@",message);
}
else if (status == kCLAuthorizationStatusNotDetermined)
{
[locationManager requestAlwaysAuthorization];
}
else
{
[locationManager startUpdatingLocation];
}
}
嗨,@Chirag可以請你添加代碼,這樣我可以幫你... – 2015-04-03 13:10:38
嗨,@JayMehta我編輯我的問題 – 2015-04-03 14:21:14
:1)增加更多的代碼(哪裏外景經理上手等)或2)添加一些日誌輸出,顯示其值傳遞到這個功能以及它是如何經常被稱爲。 – stk 2015-04-03 21:07:46