iOS 16 开发:Action 扩展、数据接收与消息应用介绍
1. 创建 iOS 16 Action 扩展
1.1 加载并转换文本
在创建 iOS 16 Action 扩展时,若要处理文本数据,可使用如下代码:
if textItemProvider.hasItemConformingToTypeIdentifier(UTType.text.identifier) {
textItemProvider.loadItem(forTypeIdentifier: UTType.text.identifier,
options: nil,
completionHandler: { (result, error) in
self.convertedString = result as? String
if self.convertedString != nil {
self.convertedString = self.convertedString!.uppercased()
DispatchQueue.main.async {
self.myTextView.text = self.convertedString!
}
}
})
}
这段代码的逻辑如下:
1. 检查 textItemProvider 是否包含符合文本类型
超级会员免费看
订阅专栏 解锁全文

1125

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



