隐藏在键盘下的 SKStoreReviewController 按钮

SKStoreReviewController buttons hidden under keyboard(隐藏在键盘下的 SKStoreReviewController 按钮)
本文介绍了隐藏在键盘下的 SKStoreReviewController 按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我的 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 按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

No resource found that matches the given name: attr #39;android:keyboardNavigationCluster#39;. when updating to Support Library 26.0.0(找不到与给定名称匹配的资源:attr android:keyboardNavigationCluster.更新到支持库 26.0.0 时) - IT屋-程序员软
How to resize UITextView on iOS when a keyboard appears?(出现键盘时如何在iOS上调整UITextView的大小?)
How to reliably detect if an external keyboard is connected on iOS 9?(如何可靠地检测 iOS 9 上是否连接了外部键盘?)
How to mimic Keyboard animation on iOS 7 to add quot;Donequot; button to numeric keyboard?(如何在 iOS 7 上模拟键盘动画以添加“完成数字键盘的按钮?)
How do I dismiss the iOS keyboard?(如何关闭 iOS 键盘?)
Is possible to simulate touch event using an external keyboard on ios jailbroken?(是否可以在 ios 越狱后使用外部键盘模拟触摸事件?)