呈现从 UITableViewCell 内部启动的 UIActivityViewController
Presenting UIActivityViewController initiating from inside UITableViewCell
下面的代码工作正常并在放入 PostsVC
(Mian View Controller)时显示 UIActivityViewController
但给出 cell does not have a member named 'presentViewController' 放置在同一个 PostsVC 视图控制器上的 UITableViewCell 内的 UIButton 的点击操作时出错。
如何在最后一行代码中引用 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)
在单元格子类中添加对视图控制器的弱引用。在 cellForRowAtIndexPath:
中设置
cell.viewController = self
然后在 cell.viewController 而不是单元格本身上调用 presentViewController 方法。
下面的代码工作正常并在放入 PostsVC
(Mian View Controller)时显示 UIActivityViewController
但给出 cell does not have a member named 'presentViewController' 放置在同一个 PostsVC 视图控制器上的 UITableViewCell 内的 UIButton 的点击操作时出错。
如何在最后一行代码中引用 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)
在单元格子类中添加对视图控制器的弱引用。在 cellForRowAtIndexPath:
中设置cell.viewController = self
然后在 cell.viewController 而不是单元格本身上调用 presentViewController 方法。