***由于未捕获的异常'NSGenericException'而终止应用程序,原因:'UIPopoverPresentationController()应当在演示发生之前设置一个非null的sourceView或barButtonItem。

最佳答案

self.dismissViewControllerAnimated(true, completion: nil)
        let textToShare:String = "Lets have a chat!";
        let activityVC:UIActivityViewController = UIActivityViewController(activityItems: [textToShare], applicationActivities: nil)
        let excludeActivities = [UIActivityTypeAirDrop, UIActivityTypePrint, UIActivityTypeSaveToCameraRoll, UIActivityTypeAssignToContact, UIActivityTypePostToFlickr, UIActivityTypePostToTencentWeibo, UIActivityTypePostToVimeo, UIActivityTypePostToTencentWeibo]
        activityVC.excludedActivityTypes = excludeActivities
        activityVC.modalPresentationStyle =  UIModalPresentationStyle.FormSheet
 presentViewController(activityVC, animated: true, completion: nil)

10-01 23:41