我正在尝试实现共享快捷方式项目(我的实现):
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if shortcutItem.type == "share"{
self.shareItem()
}
}
func shareItem() {
let visitedlink = "http://google.com"
let myWebsite = NSURL(string: visitedlink)
let img: UIImage = UIImage(named:"Logo")!
guard let url = myWebsite else {
print("nothing found")
return
}
let shareItems:Array = [img,url]
let activityViewController:UIActivityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil)
activityViewController.excludedActivityTypes = [UIActivityType.print, UIActivityType.postToWeibo, UIActivityType.copyToPasteboard, UIActivityType.addToReadingList, UIActivityType.postToVimeo, UIActivityType.message, UIActivityType.mail]
self.present(activityViewController, animated: true, completion: nil)
}
但在这一行:
self.present(activityViewController, animated: true, completion: nil)
我收到此错误:
Value of type AppDelegate has no member of present
你们中的任何人都知道为什么我会收到此错误吗?或解决这个问题?
我会非常感谢你的帮助。