Reputation: 6175
My app is just uploaded on the app store. In my app I have a button that gives direction to a specific location from the current location. In the simulator everything works fine, but on the iphone when the button is taped it loads the map, and so you would press the iphone button to exit the map but when I tap on my app to open it again, it loads the map again even after an hour!
basically it keeps loading the map when the app is loaded every time after the direction button is pressed.
so you open the app and the app only opens the map!
I have no idea what's going on!
here is the code I used,
- (IBAction)directionButton {
[super viewDidLoad];
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
double currentLat = newLocation.coordinate.latitude;
double currentLong = newLocation.coordinate.longitude;
NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%@",
currentLat,
currentLong,
[address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
}
Upvotes: 0
Views: 120
Reputation: 6175
The solution was quite simple. when you are done updating the location call the following method,
[manager stopUpdatingLocation];
where manager is your instance of CLLocationManager.
Upvotes: 0
Reputation: 1105
Upvotes: 1
Reputation: 6175
I just fixed this by preventing the app from running on the background.
so you would need to add a new row to your info.plist and make it "Application does not run in background", have the box in front of it checked.
Upvotes: 0
Reputation: 8845
Your question isn't very clear, but from what I understand, it is simply a matter of dismissing the view containing the map and returning to the previous view. How are you changing the view from the view with the button to the view with the map?
Upvotes: 0