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!
}
}
})
}
此代码会检查 textItemProvider 是否包含文本类型的项目。若包含,则加载该文
超级会员免费看
订阅专栏 解锁全文
57

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



