iOS开发中的用户界面处理技巧
1. 处理通知响应
当用户对通知做出响应时, userNotificationCenter(_:didReceive:withCompletionHandler:) 函数会被调用。此函数的 didReceive 参数类型为 UNNotificationResponse 。若我们安排了 UNTextInputNotificationAction 类型的文本通知操作,就需查找 UNTextInputNotificationResponse 类型的响应。若为该响应对象,就能读取其 userText 属性,此属性保存着用户在屏幕上输入的文本。示例代码如下:
func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
guard let response = response as? UNTextInputNotificationResponse,
response.actionIdentifier == "enter" else {
completionHandler()
return
}
print(re
超级会员免费看
订阅专栏 解锁全文
1185

被折叠的 条评论
为什么被折叠?



