下面的代码工作正常并在放入UIActivityViewController
(Mian View Controller)时显示PostsVC
,但是 单元格没有名为' presentViewController'将UIButton置于同一PostsVC视图控制器内的UITutViewCell内部的点击操作内时出现 错误。
如何在最后一行代码中引用PostsVC来呈现它?
let appAddress = "https://itunes.apple.com/app/id978654?ls=1&mt=8"
let shareText = "Share our app "
let activityViewController : UIActivityViewController = UIActivityViewController(activityItems: [shareText, appAddress], applicationActivities: nil)
self.presentViewController(activityViewController, animated: true, completion: nil)
答案 0 :(得分:1)
在您的单元子类中为视图控制器添加弱引用。在cellForRowAtIndexPath中设置:
cell.viewController = self
然后在cell.viewController而不是单元本身上调用presentViewController方法。