Resolved App Location Permission

Discussion in 'iOS Programming' started by Glenn1602, Oct 25, 2011.

  1. Glenn1602, Oct 25, 2011
    Last edited: Oct 25, 2011

    Glenn1602 macrumors newbie

    Joined:
    Oct 25, 2011
    #1
    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!
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    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.)
     
  3. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #3
    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...)
     
  4. Glenn1602 thread starter macrumors newbie

    Joined:
    Oct 25, 2011
    #4
    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.
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    That would really help.

    Do you have view controllers for these various views?
     
  6. Glenn1602 thread starter macrumors newbie

    Joined:
    Oct 25, 2011
    #6
    They both have their own view controller, if that's what you mean!
     
  7. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    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?
     
  8. Glenn1602 thread starter macrumors newbie

    Joined:
    Oct 25, 2011
    #8
    Correct! Shouldn't they be?
     
  9. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    I normally put the location code in the app delegate, but don't get me wrong: your approach is fine, too!
     
  10. Glenn1602 thread starter macrumors newbie

    Joined:
    Oct 25, 2011
    #10

    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! :)
     

Share This Page