Reputation: 4632
Below code work fine and presents UIActivityViewController
when put inside PostsVC
(Mian View Controller) but gives cell does not have a member named 'presentViewController' error when put inside tap action of a UIButton which is placed inside UITableViewCell on the same PostsVC view controller.
How do I reference to PostsVC in the last line of code to present it ?
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)
Upvotes: 0
Views: 1035
Reputation: 9397
Add a weak reference to your view controller in your cell subclass. Set this in cellForRowAtIndexPath:
cell.viewController = self
Then call the presentViewController method on cell.viewController rather than the cell itself.
Upvotes: 1