2010-05-22 2 views
0

테이블의 위치 거리를 계산하는 uitableview를 만들었습니다. 나는이 코드를 인덱스 경로의 행에 대해 셀에 사용했다.uitableview에서 텍스트가 두 번 인쇄됩니다.

 NSString *lat1 = [object valueForKey:@"Lat"]; 

    NSLog(@"Current Spot Latitude:%@",lat1); 

    float lat2 = [lat1 floatValue]; 
    NSLog(@"Current Spot Latitude Float:%g", lat2); 

    NSString *long1 = [object valueForKey:@"Lon"]; 

    NSLog(@"Current Spot Longitude:%@",long1); 

    float long2 = [long1 floatValue]; 
    NSLog(@"Current Spot Longitude Float:%g", long2); 

    //Getting current location from NSDictionary 

    CoreDataTestAppDelegate *appDelegate = (CoreDataTestAppDelegate *) [[UIApplication sharedApplication] delegate]; 
    NSString *locLat = [NSString stringWithFormat:appDelegate.latitude]; 
    float locLat2 = [locLat floatValue]; 
    NSLog(@"Lat: %g",locLat2); 

    NSString *locLong = [NSString stringWithFormat:appDelegate.longitude]; 
    float locLong2 = [locLong floatValue]; 
    NSLog(@"Long: %g",locLong2); 

    //Location of selected spot 
    CLLocation *loc1 = [[CLLocation alloc] initWithLatitude:lat2 longitude:long2]; 

    //Current Location 
    CLLocation *loc2 = [[CLLocation alloc] initWithLatitude:locLat2 longitude:locLong2]; 

    double distance = [loc1 getDistanceFrom: loc2]/1600; 

    NSMutableString* converted = [NSMutableString stringWithFormat:@"%.1f", distance]; 

    [converted appendString: @" m"]; 

그것은 당신이 페이지의 높이를 넘어 스크롤 할 때의 거리 텍스트가 자세한 텍스트 레이블의 맨 위에 중복 난 그냥 발견 한 문제에서 떨어져 잘 작동합니다.

여기에 제가 의미하는 스크린 샷이 있습니다.

이유는 무엇입니까?

답변

0

스크린 샷을 볼 수 없지만 문자열을 만드는 데 사용 된 코드에 문제가 표시되지 않습니다. 적어도 가비지 콜렉션을 사용하고 있다면 - 수동 메모리 관리를 사용한다면 유지/해제하고 싶을 것입니다. 또한 .xib 파일에서 테이블 구성과 관련된 문제 일 수 있습니다. 마지막으로, 사용자 정의보기 또는 표준 코코아 컨트롤 만 사용하고 있습니까? 사용자 지정 컨트롤을 사용하면 드로잉/새로 고침 문제가 발생할 수 있습니다.