Text being printed twice in uitableview

Posted by user337174 on Stack Overflow See other posts from Stack Overflow or by user337174
Published on 2010-05-22T21:18:56Z Indexed on 2010/05/22 21:20 UTC
Read the original article Hit count: 156

Filed under:
|
|

I have created a uitableview that calculates the distance of a location in the table. I used this code in cell for row at index path.

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

It works fine apart from a problem i have just discovered where the distance text is duplicated over the top of the detailed text label when you scroll beyond the height of the page.

here's a screen shot of what i mean.

Any ideas why its doing this?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c