Presenting UIActivityViewController initiating from inside UITableViewCell
下面的代码可以正常工作,并在放入
如何在最后一行代码中引用 PostsVC 来呈现它?
1 2 3 4 | 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) |
在单元子类中添加对视图控制器的弱引用。在 cellForRowAtIndexPath:
中设置
1 | cell.viewController = self |
然后调用 cell.viewController 上的 presentViewController 方法而不是单元格本身。