问题
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];
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.
回答1:
i had use bellow code..
First Add MKReverseGeocoderDelegate
in .h
file..
after create object of MKReverseGeocoder
in .h
file like belolow..
MKReverseGeocoder *mkReverseGeocoder;
and then use it like bellow on your UIButton
Action event
-(IBAction)btnFindMe_Clicked:(id)sender{
if(mkReverseGeocoder)
{
[mkReverseGeocoder autorelease];
}
mkReverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:[currLocation coordinate]];
[mkReverseGeocoder setDelegate:self];
[mkReverseGeocoder start];
}
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], ];
}
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..
来源:https://stackoverflow.com/questions/15682595/in-mkmapkit-how-to-get-the-current-location-detail-in-textfield-or-tableview