Skip to content

Instantly share code, notes, and snippets.

@DonMag
Forked from MikeTradr/SHARE.SWIFT
Created December 14, 2016 17:32
Show Gist options
  • Select an option

  • Save DonMag/00670cfaec0791224aad942d69aab573 to your computer and use it in GitHub Desktop.

Select an option

Save DonMag/00670cfaec0791224aad942d69aab573 to your computer and use it in GitHub Desktop.
func shareCell (actionType:String, img:UIImage) {
switch (actionType){
case "textImage":
let objectsToShare = [img]
let activityVC = UIActivityViewController(
activityItems: objectsToShare,
applicationActivities: nil
)
let mailSubject:String = "🗓 My Event..."
activityVC.setValue(mailSubject, forKey: "Subject")
activityVC.completionWithItemsHandler = {
(activityType, completed, items, error) in
guard completed else { print("User cancelled."); return }
print("Completed With Activity Type: \(activityType)")
}
// must be PopOver on iPad --- will be ignored on iPhone
//TODO FIX activityVC.popoverPresentationController?.barButtonItem = sender as? UIBarButtonItem
self.presentViewController(activityVC, animated: true, completion: nil)
break;
default:
break;
}
}
//================================
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.None)
dispatch_async(dispatch_get_main_queue()) {() -> Void in
let ccl = tableView.cellForRowAtIndexPath(indexPath)
if let snap1 = ccl?.takeSnapshot() {
self.shareCell("textImage", img: snap1)
}
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment