My app's application(_:didFinishLaunchingWithOptions:launchOptions:)
is creating an overlay like this:
window.makeKeyAndVisible()
let launchStoryboard = UIStoryboard(name: "LaunchScreen", bundle: nil)
let overlayView = launchStoryboard.instantiateInitialViewController()!.view!
window.addSubview(overlayView)
The app's initial view controller as defined in Main.storyboard
is a UITabBarController
whose 1st tab contains a UINavigationController
. viewDidLoad()
of its root view controller calls EKEventStore.authorizationStatus(for:)
.
At this point the app seemingly stalls and only the overlay is visible. When I stop the app the dialog box that asks whether the app should be allowed to access the calendar appears. It was apparently hidden below the overlay.
How can I ensure that the dialog box appears at the very front of the screen so the user gets a chance to answer its actual question?
UPDATE Here is more information about the general context in response to questions: The reason for the code in the app's delegate is that -- unless it has occurred on a previous launch -- I need to prompt the user for server credentials, obtain data from the server and store some of this data in EKEvent
s. The overlay supports presenting the view controller for obtaining the user’s credentials (see here). The overlay will be removed when data has been received from the server. The call to makeKeyAndVisible
is necessary in order for UIApplication.shared.keyWindow
to receive a value despite the early stage in the app’s life cycle. That value is required for presenting the said view controller for obtaining credentials.