我的 swift iOS 应用程序有一个带有键盘显示的活动文本字段.每次用户点击键盘上的返回键时,我都会调用
SKStoreReviewController.requestReview()
这听起来可能有点过分,但是一旦用户给出了评论,上面的声明将不会做任何事情,所以我认为我的方法是正确的.
问题是在较小的屏幕设备(iPhone 5 等)上,显示的 SKStoreReviewController 的按钮隐藏在键盘下方.
因此用户卡住了,因为他们无法关闭 SKStoreReviewController.我不想为用户添加键盘隐藏按钮.
我如何知道 SKStoreReviewController
何时显示,以便以编程方式隐藏键盘?
你无法判断它是否正在显示.
您可以在 SKStoreReviewController
这告诉您,您无法通过 presentedViewController
等属性尝试挖掘任何内容,以尝试预测屏幕是否正在呈现.
通常,如果您要呈现 UIAlertController
或任何与此相关的 UI 元素,您会看到构成它的 UI 部分堆叠在一起,这表明您可以访问关联的属性以找出什么正在呈现.在这个类中,这些都没有提供,因此您的应用程序不会注意到正在发生的事情.
以下屏幕截图说明了当屏幕上有多个元素时视图层次结构的样子:
正如 Apple 在课程文档中提到的那样,您需要开发自己的逻辑,以便在它不会呈现您当前遇到的问题时呈现它.
My swift iOS app has an active textfield with keyboard showing. Everytime user taps the return key on keyboard, I call
SKStoreReviewController.requestReview()
This may sound excessive but once the user has given the review, above statement will not do anything so I think my approach is correct.
Problem is that on smaller screen devices (iPhone 5 etc), the displayed SKStoreReviewController's buttons are hidden under the keyboard.
So the user gets stuck as they cannot dismiss the SKStoreReviewController. I do not want to add a keyboard hide button for the user.
How can I know when SKStoreReviewController
did display so I can programmatically hide the keyboard?
There is no way for you to tell if it is being displayed.
You can read the documentation on SKStoreReviewController
here, which shows only the requestReview() function you use to call it.
But, if you want to dig deeper, I provide the following screenshot which shows what the Debug View Hierarchy looks like while displaying the request.
What this tells you, is that there is nothing you can try to dig down to via properties such as presentedViewController
in an attempt to divine if the screen is being presented.
Normally, if you are presenting a UIAlertController
, or any UI element for that matter, you will see the UI pieces stacked together that form it, indicating that you can access associated properties to find out what is being presented. With this class, none of that is provided so your app is oblivious to what is going on.
The following screenshot illustrates what a view hierarchy looks like when you have multiple elements on the screen:
As Apple alludes to in the class documentation, you need to develop your own logic for presenting it at a time when it will not present the issue you are currently experiencing.
这篇关于隐藏在键盘下的 SKStoreReviewController 按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!