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中获取当前位置详细信息,如果有人知道,请帮助我。
答案 0 :(得分: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], ];
}
另请参阅此链接以示例,但其另一个代码..上面是我的自定义代码... how-to-get-current-latitude-and-longitude-in-iphone/
我希望这对你有所帮助..