【发布时间】:2015-06-16 16:37:58
【问题描述】:
我有一个用于共享按钮的 UIActivityViewController。对于 iPhone,我将它作为常规的 UIActivityViewController,对于 iPad,它在 PopOverViewController 中。这是我的代码
let textToShare = "Check out this website!"
if let myWebsite = NSURL(string: "http://www.apple.com/") {
let objectsToShare = [textToShare, myWebsite]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
if let popUpVC = activityVC.popoverPresentationController {
popUpVC.permittedArrowDirections = .Any
popUpVC.sourceRect = share.frame
}
self.view?.window?.rootViewController?.presentViewController(activityVC, animated: true, completion: nil)
}
当我在 iPad 上按下共享按钮时,它会崩溃并显示 (lldb)。但是,当我从视图中看到它时,它可以工作,但位置不正确。这是我目前使用的代码。
popUpVC.sourceView = self.view
【问题讨论】:
标签: ios xcode ipad uipopovercontroller uiactivityviewcontroller