【发布时间】:2019-01-07 07:09:33
【问题描述】:
我通过我的应用程序中的 UIActivityViewController 与空投共享 .zip 文件。
@IBAction func shareAction(_ sender: Any) {
let newFileURL = NSHomeDirectory() + "/Documents/test.zip"
let url = NSURL(fileURLWithPath: newFileURL)
let shareItems = [url] as [Any]
let ac = UIActivityViewController(activityItems: shareItems as [Any], applicationActivities: [])
ac.excludedActivityTypes = [UIActivity.ActivityType.assignToContact, UIActivity.ActivityType.addToReadingList]
if(UIDevice.current.userInterfaceIdiom == .pad) {
let popover = ac.popoverPresentationController
popover?.sourceView = shareButton
popover?.sourceRect = CGRect(x: 150, y: 40, width: 0, height: 0)
}
present(ac, animated: true, completion: nil)
func completionHandler(activityType: UIActivity.ActivityType?, shared: Bool, items: [Any]?, error: Error?) {
if (shared) {
print("Share Succeed!")
}
else {
print("Share failed!")
}
}
ac.completionWithItemsHandler = completionHandler
}
我想知道: 接收方使用什么应用程序打开我发送的文件? / 接收器是否安装了我的应用程序? 这可以实现吗?
【问题讨论】:
标签: ios