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

Glenn1602

macrumors newbie
Original poster
Oct 25, 2011
5
0
Hey,

My app takes the users location, and tells them how far away they are from a destination. This information is then shown in a table view. My problem is that the dialog box asking for permission to use the users location only appears for a split second before the table view, not giving the user enough time to allow the use of their location. I've tried calling [CLLocationManager startUpdatingLocation] when the app loads, in an attempt to force the app to display the dialog box early, but that doesn't work.

Is there any way to either stop the dialog box from disappearing so quickly, or to get the app to ask for permission as soon as it loads?

Thanks!
 
Last edited:

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
The prompt to request permission to use your location is an alert view. Therefore, it should appear until the user takes an action to dismiss it (via one of the buttons). I'm not sure how yours would be going away before that.

Anyways, it's hard to debug descriptions of code. Please provide actual code and actual results (like screenshots, console messages, etc.)
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,563
6,062
It should be noted that only one alert view may be displayed at a time... if you're including code in there someplace to display a different alert view, the location one could be shoved aside (but even then, after your alert view goes away the location one should come back...)
 

Glenn1602

macrumors newbie
Original poster
Oct 25, 2011
5
0
dejo - I'm away from the mac right now, but when I get back I'll post some code/screenshots!

All the location code is in the TableView. I push this view from a standard UIView. The weird thing is the Alert View appears before the TableView does. It's almost as if the TableView is sitting on top of the Alert.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
dejo - I'm away from the mac right now, but when I get back I'll post some code/screenshots!
That would really help.

All the location code is in the TableView. I push this view from a standard UIView. The weird thing is the Alert View appears before the TableView does. It's almost as if the TableView is sitting on top of the Alert.
Do you have view controllers for these various views?
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
They both have their own view controller, if that's what you mean!

Yes, that's what I mean. In that case, when you say "All the location code is in the TableView", what you mean is "All the location code, including the delegate methods for the CLLocationManager, is in the UITableViewController subclass", correct?
 

Glenn1602

macrumors newbie
Original poster
Oct 25, 2011
5
0
Yes, that's what I mean. In that case, when you say "All the location code is in the TableView", what you mean is "All the location code, including the delegate methods for the CLLocationManager, is in the UITableViewController subclass", correct?

Correct! Shouldn't they be?
 

Glenn1602

macrumors newbie
Original poster
Oct 25, 2011
5
0
I normally put the location code in the app delegate, but don't get me wrong: your approach is fine, too!


Got it solved! Feel quite stupid for not noticing it; I'd forgotten to turn ARC off whenever I started the project. It was releasing the TableView once it was loaded, and taking the AlertView with it!

Thanks for all your help though! :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.