ios - 在iOS中检测“触摸返回通话”的点击
问题描述
有没有办法检测用户是否点击了“触摸返回通话”(https://i.stack.imgur.com/9m9xi.jpg)?也许是某种委托方法,或者像 inapplication(_:didFinishLaunchingWithOptions:)
解决方案
class ViewController: UIViewController {
private var observer: NSObjectProtocol?
override func viewDidLoad() {
super.viewDidLoad()
observer = NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: .main) { [unowned self] notification in
// do whatever you want when the app is brought back to the foreground
}
}
}
只需在您调用Kit viewcontroller 类中的此代码,并通过点击“触摸以返回通话”来检查用户何时返回应用程序
推荐阅读
- c++ - C++字节序会影响fstream的读写功能吗?
- react-native - 如果通过子组件调用 Redux 属性增量不起作用
- javascript - 带有 Promise 的 Firestore 循环
- flutter - Flutter - 使用 TextEditingController 检测最后输入的字符是否与特定字符匹配
- html - 如何使用css独立滚动两个div
- java - 使用 java 中的 apache poi 在 Doc 文件中的表格单元格中输入文本
- hibernate - 在 Spring Data JPA 中选择带有动态列的查询
- google-drive-api - Google drive api Files:获取未列出完整元数据
- python - 从列出的目录中压缩目录
- c# - 在我们的 .net 项目中更改 MSBuild 工具集 (ToolsVersion) 的缺点是什么?