
// testLocationVIEwController.m
//作者:禚来强 iphone开发*****:79190809 邮箱:zhuolaiqiang@gmail.com // testLocation // // Created by laiqiang zhuo on 5/11/11. // copyright 2011 mtime. All rights reserved. // #import "testLocationVIEwController.h" @implementation testLocationVIEwController @synthesize locationmanger = _locationmanger; - (voID)dealloc { [super dealloc]; [_locationmanger release]; } #pragma mark - VIEw lifecycle // Implement vIEwDIDLoad to do additional setup after loading the vIEw,typically from a nib. - (voID)vIEwDIDLoad { [super vIEwDIDLoad]; cityLabel = [[[UILabel alloc] initWithFrame: CGRectMake(20,30,100,100)] autorelease]; [self.vIEw addSubvIEw: cityLabel]; /* self.locationmanger = [[CLLocationManager alloc] init]; _locationmanger.delegate = self; _locationmanger.desiredAccuracy = kCLLocationAccuracyBest; [_locationmanger startUpdatingLocation]; */ _locationmanger = [[CLLocationManager alloc] init]; _locationmanger.delegate = self; _locationmanger.distanceFilter = 1; _locationmanger.desiredAccuracy = kCLLocationAccuracyBest; [_locationmanger startUpdatingLocation]; } - (voID)vIEwDIDUnload { [super vIEwDIDUnload]; // Release any retained subvIEws of the main vIEw. // e.g. self.myOutlet = nil; } - (BOol)shouldautorotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)interfaceOrIEntation { // Return YES for supported orIEntations return YES; } - (voID)locationManager:(CLLocationManager *)manager dIDFailWithError:(NSError *)error { } - (voID)locationManager:(CLLocationManager *)manager dIDUpdatetoLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { CLLocationdistance l = newLocation.coordinate.latitude;//得到经度 CLLocationdistance v = newLocation.coordinate.longitude;//得到纬度 NSLog(@"%f %f",l,v); CLLocation *new = [[CLLocation alloc] initWithLatitude: 11.0 longitude: 12.0]; CLLocationdistance u = [newLocation distanceFromLocation: new]; NSLog(@"%f",u); [self startedReverseGeoderWithLatitude: l longitude: v]; } - (voID)startedReverseGeoderWithLatitude:(double)latitude longitude:(double)longitude{ CLLocationCoordinate2D coordinate2D; coordinate2D.longitude = longitude; coordinate2D.latitude = latitude; MKReverseGeocoder *geoCoder = [[MKReverseGeocoder alloc] initWithCoordinate:coordinate2D]; geoCoder.delegate = self; [geoCoder start]; } #pragma mark - - (voID)reverseGeocoder:(MKReverseGeocoder *)geocoder dIDFindplacemark:(MKPlacemark *)placemark { Nsstring *subthroung=placemark.subThoroughfare; Nsstring *local=placemark.locality; NSLog(@"城市名:%@-%@-%@",placemark.locality,local,subthroung); if (local) { [cityLabel setText:local]; } } - (voID)reverseGeocoder:(MKReverseGeocoder *)geocoder dIDFailWithError:(NSError *)error { } @end 总结
以上是内存溢出为你收集整理的iphone ipad 显示当前城市名称全部内容,希望文章能够帮你解决iphone ipad 显示当前城市名称所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)