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

これは、現在の場所を指すために使用されます。テキストフィールドまたはテーブルビューで現在の場所の詳細を取得したいので、知っている人がいれば助けてください。

4

1 に答える 1

1

以下のコードを使用していました..

最初MKReverseGeocoderDelegate.hファイルに追加..

MKReverseGeocoder以下のようなファイル内のオブジェクトを作成した後.h..

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/

于 2013-03-28T13:11:26.043 に答える