Frage

Ich frage mich, wenn es weg ist, die lat zu senden und zu lange an einem Standort der Person auf eine URL? Es wäre auch mit der Datenbank übereinstimmen müssen ihre UDID-Nummer haben.

Hier ist, was ich habe, so weit:

-(void)viewDidLoad {    
     NSString *query = [[NSString alloc] initWithFormat:
                          @"http://example.com/ihome.php?uid=%@", 
                          [[UIDevice currentDevice] uniqueIdentifier], 
                          @"&year=2010%@"];
     NSURL *url = [[NSURL alloc] initWithString:query];
     NSURLRequest *requestObj = [ NSURLRequest requestWithURL: url ];
     webView.opaque = NO;
     webView.backgroundColor = [UIColor clearColor];
     [webView loadRequest: requestObj ];
}
War es hilfreich?

Lösung

Sie haben die Länge und die Breite zu berechnen, bevor die URL anzufordern.

- (void) viewDidLoad {
    self.locationManager = [[[CLLocationManager alloc] init] autorelease];
    self.locationManager.delegate = self; // send location updates to this object
    [self.locationManager startUpdatingLocation];
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
     NSLog(@"Your location: %@", [newLocation description]);

     NSString *query = [[NSString alloc] initWithFormat:
                          @"http://mysite.com/ihome.php?uid=%@&longitude=%d&latitude=%d", 
                          [[UIDevice currentDevice] uniqueIdentifier], 
                          @"&year=2010%@",
                          newLocation.longitude,
                          newLocation.latitude];
     NSURL *url = [[NSURL alloc] initWithString:query];
     NSURLRequest *requestObj = [ NSURLRequest requestWithURL: url ];
     webView.opaque = NO;
     webView.backgroundColor = [UIColor clearColor];
     [webView loadRequest: requestObj ];

}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
    NSLog(@"Error: %@", [error description]);
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top