I’m trying to implement share button in TableViewCell that uses data for the text and image. This code works perfect but I want the data from the TableViewCell to be used dynamically.
@IBAction func tapShareButton(_ sender: UIButton) {
//Shoename should be the releasename
let firstActivityItem = "Find out everywhere the *shoename* is available to purchase"
let secondActivityItem : NSURL = NSURL(string: "http//:urlyouwant")!
// Image should be the releaseimage
let image : UIImage = UIImage(named: "image.jpg")!
let activityViewController : UIActivityViewController = UIActivityViewController(
activityItems: [firstActivityItem, secondActivityItem, image], applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = (sender )
activityViewController.popoverPresentationController?.sourceRect = CGRect(x: 150, y: 150, width: 0, height: 0)
// Anything you want to exclude
activityViewController.excludedActivityTypes = [
UIActivity.ActivityType.postToWeibo,
UIActivity.ActivityType.print,
UIActivity.ActivityType.assignToContact,
UIActivity.ActivityType.saveToCameraRoll,
UIActivity.ActivityType.addToReadingList,
UIActivity.ActivityType.postToFlickr,
UIActivity.ActivityType.postToVimeo,
UIActivity.ActivityType.postToTencentWeibo
]
self.presentViewController(activityViewController, animated: true, completion: nil)
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "ReleaseCell", for: indexPath) as! ReleaseTableViewCell
var release: ReleaseModel
release = releasesData[indexPath.row]
cell.releaseType.text = release.releasetype
cell.releaseName.text = release.releasename
cell.releaseDate.text = release.releasedate
cell.releaseImage.sd_setImage(with: URL(string: release.releaseimage!), placeholderImage: UIImage(named: "placeholder1"))
cell.delegate = self
return cell
}