ios - 如果用户向上滚动控制中心,如何从 iOS 键盘扩展检测到?

标签 ios objective-c swift uikeyboard ios-extensions

我开发了一个 iOS 键盘扩展,并且我在键盘上使用滚动手势。有时,当使用键盘时,我向上滚动控制中心,但键盘无法正常工作。有什么方法可以检测控制中心是否可见或不可见?

最佳答案

你不能直接这样做。您最多可以知道的是您的应用程序被停用然后再次激活。可能是因为控制中心,可能是因为通知中心,可能是因为有电话打进来,可能是因为用户进入应用程序切换器然后又回来了......

以下是您可以尝试的可能解决方法:

It is the UIWindow subclass to enable behavior like adaptive round-corners & detecting when Control Center is opened. This UIWindow subclass does probably the thing you want. You simply subscribe to an NSNotification and can react to the user opening Control Center. Detailed instructions and setup on Github

https://github.com/aaronabentheuer/AAWindow

[AAWindow: The way this is accomplished is by using a combination of NSTimer and overwriting sendEvent in UIWindow to receive all touches without blocking them. So you basically receive all touches check if they are near the lower edge of the screen, if yes set a timer for a half a second and if during this timer is running applicationWillResignActive is called you can be almost certain that ControlCenter is opened. The time has to vary if there's no statusbar, because then the app is in fullscreen and it can take the user up to 3 seconds to launch Control Center.]

希望它能帮助您找到问题的确切解决方案。

关于ios - 如果用户向上滚动控制中心,如何从 iOS 键盘扩展检测到?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31785136/

相关文章:

Swift 4 两个方向键与 spritekit

ios - 如何通过Arkit人脸跟踪获取3D位置数据?

ios - 在 iOS 6 中无法使用相机扫描 PDF 417 条码

iphone - 无法将字符串保存到 SQLite 数据库中(SQLITE_DONE 不返回 true)

objective-c - 升级到 iOS 6 后 UISegmentedControl 的显示问题

swift - 是第一个(其中 :) Method always O(n) or it can be O(1) with usage of Set or Dictionary?

ios - 以编程方式从底部裁剪图像

ios - 如何使用一对多关系

ios - 如何在 objective-c 中交换字符串而没有任何空格?

objective-c - 是否可以按内容比较两个 Objective-C block ?