In my opinion, it seems that the class is intended to be a subclass of functionality.
You can make a very simple subclass if you want to make it dynamic
enum ComposeServiceResult { case Cancel case Post } class ComposeServiceViewController: SLComposeServiceViewController { var completionHandler : ((result:ComposeServiceResult, text:String) -> Void)! override func didSelectCancel() { completionHandler(result: .Cancel, text: self.contentText) self.navigationController?.dismissViewControllerAnimated(true, completion: nil) } override func didSelectPost() { completionHandler(result: .Post, text: "") self.navigationController?.dismissViewControllerAnimated(true, completion: nil) } }
and then introduce him
var composeVC = ComposeServiceViewController() composeVC.title = "Facebook" composeVC.placeholder = "Add a caption!" composeVC.completionHandler = completionHandler composeVC.modalPresentationStyle = .OverCurrentContext; presentViewController(composeVC, animated: true, completion: nil)
I also think that you can delve into the SLComposeSheetConfigurationItem for better customization, but I did not do it myself.
source share