I have a tap gesture action which opens a Apple App Store product display:
let storeProductViewController = SKStoreProductViewController()
@objc func adTap(sender: UITapGestureRecognizer? = nil) -> Void {
if adAppID.isEmpty {return}
let paramDict = [SKStoreProductParameterITunesItemIdentifier: adAppID]
storeProductViewController.loadProduct(withParameters: paramDict, completionBlock: { (status: Bool, error: Error?) -> Void in
if status {
// self.storeProductViewController.edgesForExtendedLayout = []
// self.storeProductViewController.additionalSafeAreaInsets = UIEdgeInsets(top: 40, left: 0, bottom: 0, right: 0)
// self.storeProductViewController.modalPresentationCapturesStatusBarAppearance = false
self.present(self.storeProductViewController, animated: true, completion: nil)
}
else {
if let error = error {
print("Error: \(error.localizedDescription)")
}
}})
}
func productViewControllerDidFinish(_ viewController: SKStoreProductViewController) {
viewController.presentingViewController?.dismiss(animated: true, completion: nil)
}
First time user taps, all well and good. Tap the standard, system-provided "Done" button and the modal Store view is popped and the user is returned to the original view in the app.
If the user taps the gestured-action view again, the Store product view is displayed, but the Done button shifted up, and is now underneath the time display above the "Safe" area. It is partly obscured by the time, and is also insensitive to a tap. Deadlock - no way to return to my App.
I did not explicitly create the Nav Controller that SKStore uses and I don't think I can get control of it.
I have tried the three approaches commented out in the code to push the presented Store view and its accessory done button down. none of the three worked.
What am I doing wrong here, or how can it be fixed?
Addendum: More failed approaches: After instantiation of the store view, I tried directly setting its view and layer frames, and I also inset the safe area and margins of the parent view - all no effect on Done button.
Further down the Rabbit hole: Comparing screenshots of the first and second calls to the StoreProductView Present (Note, two different products, but that does not matter, I tried them all!), we can see that the vertical offset to the store App Icon and Name are the same for both views. It is only the "Done" button that has moved from it's normal place to up under the time/location in use area.