我正在iphone sdk4.0上做一個應用程序。在那沒有更新的位置方法調用。 我已經給出了我的代碼below.Please help.Thanks提前。didUpdateLocation方法從來沒有叫
-(id)init
{
[super init];
obj=[[UIApplication sharedApplication]delegate];
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
//locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m
[locationManager startUpdatingLocation];
return self;
}
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
NSLog(@"%f",newLocation.coordinate.latitude);
NSLog(@"%f",newLocation.coordinate.longitude);
obj=[[UIApplication sharedApplication]delegate];
location=[[CLLocation alloc]initWithLatitude:newLocation.coordinate.latitude longitude:newLocation.coordinate.longitude];
obj.lattitude1=[NSString stringWithFormat:@"%f",newLocation.coordinate.latitude];
obj.longitude1=[NSString stringWithFormat:@"%f",newLocation.coordinate.longitude];
//location=[[CLLocation alloc]initWithLatitude:39.9883 longitude:-75.262227];
}
終於工作了......我沒有做任何事情,我只是做了一個新項目,並複製了它的所有類。我不知道如何?但它的工作.. – 2011-03-23 05:11:01