在MKMapkit中如何获取textfield或tableview中的当前位置详细信息 [英] in MKMapkit how to get the current location detail in textfield or tableview

查看:99
本文介绍了在MKMapkit中如何获取textfield或tableview中的当前位置详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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];

这用于指向当前位置。现在我想在textfield或tableview中获取当前位置详细信息,所以如果有人知道的话,请帮助我。

This is used to point the current location. Now i want to get the current location detail in textfield or tableview so please help me if any one know.

推荐答案

我使用过下面的代码..

i had use bellow code..

首先在 .h MKReverseGeocoderDelegate >文件..

First Add MKReverseGeocoderDelegate in .h file..

.h MKReverseGeocoder 对象后$ c>像belolow这样的文件..

after create object of MKReverseGeocoder in .h file like belolow..

MKReverseGeocoder *mkReverseGeocoder;

然后在你的 UIButton 动作事件

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

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

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

这个bellow方法是 MKReverseGeocoder <的委托方法/ code>

and this bellow methods are delegate methods of 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 /

Also See this link with example but its another code.. above is my custom code... how-to-get-current-latitude-and-longitude-in-iphone/

我希望这对你有所帮助..

i hope this is helpful to you..

这篇关于在MKMapkit中如何获取textfield或tableview中的当前位置详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆