快速用户界面 |如何使用 share sheet 复制本地化字符串?
SwiftUI | How to use share sheet to copy localized strings?
我添加了分享 sheet 按钮,它非常适合我的英文文本(复制、共享)但是对于本地化文本,应用程序在我添加 LocalizedStringKeys()
时挂起并崩溃,当我不添加时'添加它,文本显示英文。
func shareSheet(){
isShareSheetShowing.toggle()
let av = UIActivityViewController(activityItems: [LocalizedStringKey(quote)], applicationActivities: nil)
UIApplication.shared.windows.first?.rootViewController?.present(av, animated: true, completion: nil)
}
可以直接使用NSLocalizedString
func shareSheet(){
isShareSheetShowing.toggle()
let av = UIActivityViewController(activityItems: [NSLocalizedString(quote, comment: "")], applicationActivities: nil) //<--Here
UIApplication.shared.windows.first?.rootViewController?.present(av, animated: true, completion: nil)
}
我添加了分享 sheet 按钮,它非常适合我的英文文本(复制、共享)但是对于本地化文本,应用程序在我添加 LocalizedStringKeys()
时挂起并崩溃,当我不添加时'添加它,文本显示英文。
func shareSheet(){
isShareSheetShowing.toggle()
let av = UIActivityViewController(activityItems: [LocalizedStringKey(quote)], applicationActivities: nil)
UIApplication.shared.windows.first?.rootViewController?.present(av, animated: true, completion: nil)
}
可以直接使用NSLocalizedString
func shareSheet(){
isShareSheetShowing.toggle()
let av = UIActivityViewController(activityItems: [NSLocalizedString(quote, comment: "")], applicationActivities: nil) //<--Here
UIApplication.shared.windows.first?.rootViewController?.present(av, animated: true, completion: nil)
}