views:

60

answers:

2

Hi everyone. I have CLLocationManager in app. So what i need is method to know did a user allow or decline current location. According users answer TableController adding value in table in specific way. I tried to [sightsTableView reloadData]; in
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation but after i choose allow or decline tableview is not reloading. I checked Apple's CLLocation reference and couldn't find something useful. UPD:here is codde sample.

 - (void)viewDidLoad {  
      super viewDidLoad];

      [[self locationManager] startUpdatingLocation]; 
      [tempTableView reloadData];
   }
 - (CLLocationManager *)locationManager {

 if (locationManager != nil) {
    return locationManager;
}

        locationManager = [[CLLocationManager alloc] init];
        [locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
        [locationManager setDelegate:self];



return locationManager;
}

  - (void)locationManager:(CLLocationManager *)manager
          didUpdateToLocation:(CLLocation *)newLocation
                 fromLocation:(CLLocation *)oldLocation {

          NSLog(@"User allow get location");
          self.locationError = NO;
          [tempTableView reloadData];

        }



- (void)locationManager:(CLLocationManager *)manager
         didFailWithError:(NSError *)error {
    NSLog(@"User declined get location");
    self.locationError = YES;
    [tempTableView reloadData];


    }

  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

 .... some big code about a sells )...

    cell.textLabel.text = array.title;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    if(self.locationError == NO){
    cell.detailTextLabel.text = @"!";
            }
            return cell;
 }

UPDATE: Actually there is no problem with reload. I got that i have problem with refresh table view. If i start to scroll table cell shows new value.

SECOND UPDATE Now the table is refreshing. The issue was how i called UITableView. I used [tempTableView reloadData];, but it's didn't work for me, so i tried to use this [self.tableView reloadData]; and now it's RELOADING values and REFRESHING it.

A: 
locmanager = [[CLLocationManager alloc] init];
[locmanager setDelegate:self];
[locmanager setDesiredAccuracy:kCLLocationAccuracyBest];

if (!locmanager.locationServicesEnabled)
{
    [contentView setText:@"Location Services Are Not Enabled"];
    return;
}
Aaron Saunders
i actually tried this method. but TableView loaded faster then "location enabler" loading. So i need to reload tebleview after user answer it.
sherilyn
this might be related http://stackoverflow.com/questions/3058927/why-the-cllocationmanager-delegate-is-not-getting-called-in-iphone-sdk-4-0
Aaron Saunders
also are you running in the simulator or on an actual device?
Aaron Saunders
i ran it on both.
sherilyn
A: 
Jacques
Yes i set a breakpoint and it's works. I also using `didFailWithError` method. See, i using `BOOL locationError = YES;` and do reload after that `[tempTableView reloadData];` in `didFailWithError`. And next where app using `locationError` is `cellForRowAtIndexPath`. `if(self.locationError == NO){ cell.detailTextLabel.text = @"1"; }`. So i think after i reload table view with `locationError == NO` it's have to work.
sherilyn
@sherilyn, can you post your code for didFailWithError and cellForRowAtIndexPath? I'm not quite following some of the stuff you just said, so it might be a lot easier to figure it out if I can see some code.
Jacques
i just posted it.
sherilyn
it doesn't change anything. table view still not reloaded (
sherilyn
app is loading with TableView then pop-up location alert.doesn't matter what i choose - table view still not reloaded, but should .
sherilyn
i updated main post.
sherilyn