我正在尝试在TableViewCell中实现将按钮用于文本和图像的共享按钮。这段代码很完美,但是我希望TableViewCell中的数据能够动态使用。
@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
}
答案 0 :(得分:0)
使用按钮位置获取单元格的indexPath,然后从模型对象中提取特定数据。
编辑:
您可以直接与if (process.env.NODE_ENV === 'development') {//path dev -> min to product
app.use('/js', express.static('client/js/dev'))
app.use('/css', express.static('client/css/dev'))
}
中的文本一起共享图像,因为在URL中共享图像之前,您需要先下载图像,否则可以通过将其保存在数组中来直接共享图像。
UIActivityViewController