Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cklongshot

macrumors newbie
Original poster
May 15, 2010
5
0
I have a button when pressed gets the users location and returns the information pushing a second view controller onto the stack. However, when i go back using the navigation controller to my first view and press the button a second time it does not seem to push the view again.

Code:
- (IBAction)CurrentLocation:(id)sender {
     [activityIndicator startAnimating];

     // Location Manager
     self.locationManager = [[CLLocationManager alloc] init];
     locationManager.delegate = self;
     locationManager.desiredAccuracy = kCLLocationAccuracyBest;
     [locationManager startUpdatingLocation];
        [super viewDidLoad];
}


-(void)locationManager:(CLLocationManager *)manager

   didUpdateToLocation:(CLLocation *)newLocation

            fromLocation:(CLLocation *)oldLocation {

     if (startingPoint == nil) {
          self.startingPoint = newLocation;
          NSString *latitudeString = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.latitude];
          NSLog(latitudeString);

          NSString *longitudeString = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.longitude];
          NSLog(longitudeString);

          // Stack next View
          StoreListingsViewController *storeListings = [[StoreListingsViewController alloc] initWithNibName:@"StoreListings" bundle:nil];

          // pass url string to next view
          storeListings.latitudeString = latitudeString;
          storeListings.longitudeString = longitudeString;
          [latitudeString release];
          [longitudeString release];
          [self.navigationController pushViewController:storeListings animated:YES];
          [storeListings release];

          // Stop checking for updates to location
          [locationManager stopUpdatingLocation];

          // Stop activity Indicator
          [activityIndicator stopAnimating];

     }
}
 
I solved this by removing my if statement for startingPoint. I was originally only accepting it to run if it was nil.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.