2013-03-28 17 views
1
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中獲取當前位置的詳細信息,所以如果有人知道,請幫助我。在MKMapkit中如何獲取文本字段或表格視圖中的當前位置詳細信息

回答

1

我不得不使用波紋管代碼..

首先添加MKReverseGeocoderDelegate.h文件..

.h文件中像belolow後創建的MKReverseGeocoder對象..

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

請參見與本實例的鏈接,但它的另一個代碼的委託方法..以上是我的自定義代碼... how-to-get-current-latitude-and-longitude-in-iphone/

我希望這是有幫助的你..

+0

@vishnu看到這個鏈接也與教程.. http://www.edumobile.org/iphone/miscellaneous/how-to-get-current-latitude-and-longitude-in-iphone/ :) –

+0

para joshi。可以幫助我。我無法獲取當前位置...我需要當前位置作爲tableview中的默認值。 – vishnu

+0

@vishnu你想當前位置??? –

相關問題