本文介绍了iPad上的UIActivityViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在使用下面的代码来显示UIActivityViewController
,当我使用Xcode 6,Swift 1.2和iOS 8时,它可以正常工作.但是,当我更新它时,它会显示UIActivityViewController
,但是它完全空白,没有任何共享选项.你有什么建议吗?
I have been using the code below to show a UIActivityViewController
which worked fine when I was using Xcode 6, Swift 1.2 and iOS 8. However when I updated it shows the UIActivityViewController
but it is completely blank without any of the sharing options. Do you have any suggestions?
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
let textToShare = textViewOne.text
let objectsToShare = [textToShare]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
let nav = UINavigationController(rootViewController: activityVC)
nav.modalPresentationStyle = UIModalPresentationStyle.Popover
let popover = nav.popoverPresentationController as UIPopoverPresentationController!
popover.sourceView = self.view
popover.sourceRect = sender.frame
self.presentViewController(nav, animated: true, completion: nil)
} else {
let textToShare = textViewOne.text
let objectsToShare = [textToShare]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
self.presentViewController(activityVC, animated: true, completion: nil)
}
推荐答案
此问题已解决.
let objectsToShare = [textToShare]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.title = "Share One"
activityVC.excludedActivityTypes = []
activityVC.popoverPresentationController?.sourceView = self.view
activityVC.popoverPresentationController?.sourceRect = sender.frame
self.presentViewController(activityVC, animated: true, completion: nil)
迅速3.0:
let objectsToShare = [textToShare]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.title = "Share One"
activityVC.excludedActivityTypes = []
activityVC.popoverPresentationController?.sourceView = self.view
activityVC.popoverPresentationController?.sourceRect = sender.frame
self.present(activityVC, animated: true, completion: nil)
这篇关于iPad上的UIActivityViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!