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