-->

在MKMapkit如何让文本框或tableview中的当前位置的细节(in MKMapkit how

2019-09-29 12:44发布

RootViewController *objYourViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
CATransition* transition = [CATransition animation];
transition.duration = 1.0;
transition.type = kCATransitionPush;
transition.subtype = kCATransitionPush;
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[self.navigationController pushViewController:objYourViewController animated:YES];

这被用来指向当前位置。 现在,我想在文本框或tableview中的当前位置的细节,请帮助我,如果有任何人知道。

Answer 1:

我不得不用波纹管代码..

首先添加MKReverseGeocoderDelegate.h文件..

后创建的对象MKReverseGeocoder.h像belolow文件..

MKReverseGeocoder *mkReverseGeocoder;

然后使用它像波纹管对你UIButton操作事件

-(IBAction)btnFindMe_Clicked:(id)sender{
    if(mkReverseGeocoder)
    {
        [mkReverseGeocoder autorelease];
    }

    mkReverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:[currLocation coordinate]];

    [mkReverseGeocoder setDelegate:self];
    [mkReverseGeocoder start];
}

这种波纹管的方法是委托方法MKReverseGeocoder

//mkreversegeocoder protocol methods

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
{

    [appDelegate hideLoadingView];
    UIAlertView *alt=[[UIAlertView alloc]initWithTitle:@"Error" message:@"Try Again After Sometime" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alt show];
    [alt release];
//    NSLog(@"\n\n Error is %@",[error description]);
}

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{

    [appDelegate hideLoadingView];
    NSLog(@"\n\n Address Dict : %@",[[placemark addressDictionary] description]);
    txtCity.text=[[placemark addressDictionary] objectForKey:@"City"];
    txtState.text=[[placemark addressDictionary] objectForKey:@"State"];
    txtAddress1.text=[[placemark addressDictionary] objectForKey:@"Street"];
    txtAddress2.text=[[placemark addressDictionary] objectForKey:@"SubLocality"];
    //[NSString stringWithFormat:@"%@", [[gpsTextView addressDictionary] description], ];
}

另请参阅例子,但它的另一个代码此链接..以上是我的自定义代码... 如何对获得电流纬度和经度,在-iphone /

我希望这对你有帮助..



文章来源: in MKMapkit how to get the current location detail in textfield or tableview