두 가지 질문이 있습니다. (처음) 나는 iPhone이 움직일 때마다 경고 상자가 나타나서 그들이 있던 위치의 경도와 그들이 현재있는 위도를 보여주기 위해 노력하고있다. 이것은 내가 작업중인 더 큰 프로젝트의 일부분을 테스트하기위한 것입니다. 문제는 경고 상자가 전혀 나타나지 않는다는 것입니다. 위치 관리자가 새 위치를 가져 오면 경고 상자에 위치를 표시해야하는 대리인이 실행되지만 아무 일도 일어나지 않는다고 생각했습니다. 대리인을 여기누구나 CLLocationManager를 사용하여 나를 도울 수 있습니까?
- (void)viewDidLoad
{
locationManager =[[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
}
됩니다 : 여기
내가 위치 관리자를 설정하고있어 어떻게
(둘째) 내가 추적 할 수있어 만족 해요 일단-(void) locationmanager: (CLLocationManager *) manager
didUpdateToLocation: (CLLocation *) newLocation
fromLocation: (CLLocation *) oldLocation
{
float oldlat;
float oldlng;
float lat;
float lng;
NSDate *oldtime;
NSDate *newtime;
lat = newLocation.coordinate.latitude;
lng = newLocation.coordinate.longitude;
newtime = newLocation.timestamp;
oldlat = oldLocation.coordinate.latitude;
oldlng = oldLocation.coordinate.longitude;
oldtime = oldLocation.timestamp;
NSNumber *oldlong = [NSNumber numberWithFloat:oldlng];
NSNumber *newlat = [NSNumber numberWithFloat:lat];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:oldlong
message:newlat
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Submit",nil];
[alert show];
새롭고 오래된 latlng은 데이터를 저장하는 가장 좋은 방법을 아는 사람이 있습니까? 내가 sqlite, 코어 데이터를 연구하고, 그냥 배열을 사용하여,하지만 난 아직도 의심의 여지가 가장 좋은 방법은 lat, lng, 타임 스탬프와 사용자 이름을 저장하는 약 200 번 하루에 약 200 사용자에게 보낸 다음 서버로 보냅니다.
저는 이것이 긴 질문 이었지만 모든 통찰력은 크게 감사 할 것입니다!
두 번째 질문에 핵심 날짜를 사용하고 싶습니다. 첫 번째 정보 - 변수의 가치는 무엇입니까? 특히, newLocation.coordinate와 oldLocation.coordinate? – TommyG
솔직히 말해서 위임 객체에서 경고를 표시 할 수 있는지 확신 할 수 없습니다 ... 부모 객체에 UIAlertView를 표시하려고 했습니까? – TommyG
또한 경고에는 문자열을 취하는 제목과 메시지가 있습니다. 거기에 NSNumber가 있습니다. 나는 이것이 심지어 컴파일된다는 것에 놀랐다. –