0
我遵循下面的代碼,輸出可以打印到控制檯,但是如何在MapView上更新?如何更新plist的地址到Mapview?
- (void)viewDidLoad {
[super viewDidLoad];
/* We have our address */
NSString *oreillyAddress = @"1005 Gravenstein Highway North, Sebastopol, CA 95472, USA";
/* We will later insert the address and the format that we want our output in, into this API's URL */
NSString *geocodingURL = @"http://maps.google.com/maps/geo?q=%@&output=%@";
/* Insert the address and the output format into the URL */
NSString *finalURL = [NSString stringWithFormat:geocodingURL, oreillyAddress, GOOGLE_OUTPUT_FORMAT_CSV];
/* Now escape the URL using appropriate percentage marks */
finalURL = [finalURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
/* Create our URL */
NSURL *urlToCall = [NSURL URLWithString:finalURL];
/* And a request for the connection using the URL */
NSURLRequest *request = [NSURLRequest requestWithURL:urlToCall];
/* We will put all the connection's received data into this instance of the NSMutableData class */
NSMutableData *newMutableData = [[NSMutableData alloc] init];
self.connectionData = newMutableData;
[newMutableData release];
NSURLConnection *newConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
/* Create the connection and start the downloading of geocoding results */
self.myConnection = newConnection;
[newConnection release];
}
- (void) viewDidUnload{
[super viewDidUnload];
[self.myConnection cancel];
self.myConnection = nil;
self.connectionData = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation {
/* Support all orientations */
return YES;
}
- (void)dealloc {
[myConnection cancel];
[myConnection release];
[connectionData release];
[super dealloc];
}
@end
@Gere Tan對此有幫助嗎?你需要進一步的幫助嗎? – 2011-06-19 18:16:26