2012-11-27 2 views
0

서비스로부터 응답을 받았고 위도 값을 얻었고 배열로 복사했습니다. 이제 다음 뷰 행을 클릭 할 때 배열을 전달하고 싶습니다.아이폰에서 다음보기로 위도 값을 전달하는 방법은 무엇입니까?

나는 일찍 장소를 통과했다. 두 번째보기에서 UITableViewController 거기에 특정 행을 클릭하면 행 텍스트 값과 특정 텍스트의 위도 값 ..... 인쇄해야합니까? 여기

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 

    NSString *myText=[places objectAtIndex:indexPath.row]; 
    NSLog(@"his is selected lattidude value:%@",myText);} 

가 나는 각각의 위도 값을 출력하기 위해 필요한이있는 행의 텍스트를 인쇄하고 ...이 가능 .... 좀 도와주세요.

+0

을 이해 바랍니다 다음 수업 에 가치를 보내기 가능한 중복 [하나의 viewController에서 다른 아이폰으로 값을 전달하는 방법] (http://stackoverflow.com/questions/8382063/how-to-pass-value-from-one-viewcontroller-to-another-in-iphone) – Pfitz

답변

1

단지

@interface SecondViewController : UIViewController{ 
    NSString *strLatLong; 
} 

@property (nonatomic, retain) NSString *strLatLong; 

@end 

와하는 .m 파일을 그냥 울부 짖는 소리처럼 합성에

..
@synthesize *strLatLong 

하고 FirstViewController 클래스는 단지 울부 짖는 코드로 밀어에서

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 

    NSString *myText=[places objectAtIndex:indexPath.row]; 
    NSLog(@"his is selected lattidude value:%@",myText); 
    SecondViewController *objSecondView = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil]; 
    objSecondView.strLatLong = myText; 
    [objSecondView.strLatLong retain]; 
    [self.navigationController pushViewController:objSecondView animated:YES]; 
    [objSecondView release]; 

} 

도움이 되시길 바랍니다 ...

+0

: 친구가 온라인으로 Gmail에 올 수 있습니다. – Vijay

+0

친구가 woking하지 않습니까 ??? – Vijay

+0

이 코드를 사용하여이 텍스트를 SecondViewController의 viewWillAppear 메서드에 인쇄 한 다음 인쇄 텍스트를 확인하거나 표시하지 않습니다. NSLog (@ "his는 선택한 lattidude 값 : % @", strLatLong); –

5

한보기에서 다른보기로 데이터를 전달하는 데는 여러 가지 방법이 있습니다.

다음과 같이 설정하십시오.

두 번째보기 컨트롤러에서 하나의 변수 만 만들면됩니다.

값을 변수에 할당하기 직전에 현재 페이지에서 탐색을 누르면.

이제 두 번째보기에서 해당 값을 쉽게 사용할 수 있습니다. .H 파일에 SecondViewController에서

1

현재의 ViewController 클래스

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 

    //NSString *myText=[places objectAtIndex:indexPath.row]; 

secondviewcontroller *ss=[[secondviewcontroller alloc]initWithNibName:@"secondviewcontroller" bundle:nil]; 

ss.StrName=[places objectAtIndex:indexPath.row]; 

     [self presentModalViewController:ss animated:YES]; 

} 
0

을에서 두 번째의 ViewController 클래스에 그 이후 .h 파일 번째의 ViewController 클래스의

@property (nonatomic) NSString *StrName; 

@synthesize.m 파일

@synthesize StrName; 

@property 만들기 두 번째 클래스의 변수를 생성하고 자신의 속성을 정의하고 첫 수업에 당신은 다음 수업이

in first class you create a variable with property like this 

@property 같은 나오지 값 (비 원자, 강력한)이 NSString * str을 하나 개의 값을 보내려면이 속성을 사용한다;

당신이 두 번째 클래스의 객체를 생성 할 때 첫 번째 클래스

는이 방법이

SecondClass *secondClass=[[SecondClass alloc]init]; 
[email protected]"value is here"; 

같은 값이 난 당신이 ;-)

관련 문제