I've got a share button following
http://www.codingexplorer.com/sharing-swift-app-uiactivityviewcontroller/
this works fine in the simulator, it does a popup from the bottom (iphone6) but of course it doesn't have the facebook and other options, just email and another. when I try this on the ipad though, it gives an error
2015-01-07 12:32:43.173 Clown[2011:2967183] LaunchServices: invalidationHandler called
2015-01-07 12:32:43.185 Clown[2011:2967169] LaunchServices: invalidationHandler called
2015-01-07 12:32:43.766 Clown[2011:2967083] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (<_UIAlertControllerActionSheetRegularPresentationController: 0x1565e7d0>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.'
he does mention in the article that an invalidationHandler will be thrown but to ignore it because everything works fine. but, it doesn't, the app crashes.
seems simliar to
http://stackoverflow.com/questions/26039229/swift-uialtertcontroller-actionsheet-ipad-ios8-crashes
but I tried to add that and my code didn't know what the alertcontroller was. here is the code
@IBAction func handleShareButton(sender: AnyObject) {
if let detail: AnyObject = self.detailItem {
let theItem = detail as [String: String]
let textToShare = "..."
if let myWebsite = NSURL(string: theItem["image"]!)
{
let objectsToShare = [textToShare, myWebsite]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
//New Excluded Activities Code
activityVC.excludedActivityTypes = [UIActivityTypeAirDrop, UIActivityTypeAddToReadingList]
self.presentViewController(activityVC, animated: true, completion: nil)
}
}
}