Tôi đang tạo một ứng dụng trên iphone sdk4.0.In đã cập nhật phương thức vị trí chưa bao giờ được gọi. Tôi đã cung cấp mã của tôi dưới đây.Xin vui lòng trợ giúp.Cảm ơn trước.Phương thức didUpdateLocation Không bao giờ được gọi
-(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];
}
cuối cùng nó hoạt động ... tôi đã không làm bất cứ điều gì.i chỉ cần thực hiện một dự án mới và sao chép tất cả các lớp trong it.i không biết làm thế nào? Nhưng nó đã làm việc .. –