Apple's core location prompt - why does it jum

2019-08-29 19:26发布

问题:

I have an iPhone app using a UINavigationController. On the fourth controller of the stack, I'm doing some Core Location stuff - so, the first couples of times that the user uses my app, they are asked if it's ok to use Location Services. This is a process that (I think) I don't have any control over.

After the user confirms, they are actually bumped back to my root view controller in the navigation controller stack. Is this a bug, am I doing something wrong, or is this expected behavior? I want the user to be able to continue on the fourth controller instead of having to re-navigate back to it.

If it's expected behaivor, I suppose I could kick in the location services as soon as the user starts the app, instead of in my fourth View Controller.

回答1:

That should not be happening i dont think, post some code, maybe you are d oing something wrong..



回答2:

If you end up removing too many views, you sometimes end up in your rootViewController or the main window.



回答3:

The problem is that I was putting all of my app initialization code in the applicationDidBecomeActive: message. After the user decides to allow location services to be used, an UIApplicationDidBecomeActiveNotification message is sent which causes the applicationDidBecomeActive message to be called.