简体   繁体   English

如何检测滑动以查看通知或控制面板

[英]How do I detect a swipe to view notifications or control panel

I notice that my app backgrounds when I swipe from the top or bottom of my screen to view notifications or control panel.当我从屏幕顶部或底部滑动以查看通知或控制面板时,我注意到我的应用程序背景。 How can I detect when these events happen?我如何检测这些事件何时发生?

When you swipe to view the notifications panel, the app doesn't remain active.当您滑动查看通知面板时,该应用程序不会保持活动状态。 This method is fired up when the app loses focus.当应用程序失去焦点时会触发此方法。 In your AppDelegate file, add the following method:在您的 AppDelegate 文件中,添加以下方法:

func applicationWillResignActive(_ application: UIApplication) {
}

To detect when the notification panel is removed ie swiped up, use要检测通知面板何时被移除,即向上滑动,请使用

func applicationDidBecomeActive(_ application: UIApplication) {
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM