Class

SLComposeServiceViewController

The SLComposeServiceViewController class provides a standard compose view you can present for social sharing extensions on both platforms. By default, the compose view includes items such as an editable text view and an indication of remaining characters, in addition to support for previewing attachments and displaying configuration items, such as an account or privacy picker.

Overview

The compose view controller gets items for the content and preview areas from the extensionContext property of the extension’s NSExtensionContext object.

Symbols

Presenting the Compose View

func presentationAnimationDidFinish()

Tells the compose view controller that the presentation animation is finished.

Posting or Canceling a Post

func cancel()

Starts the animated dismissal of the compose view.

func didSelectCancel()

Sent to the compose view after the cancel animation finishes.

func didSelectPost()

Sent to the compose view after the post animation finishes.

Validating Content

var charactersRemaining: NSNumber!

The number of characters remaining in a custom character limit.

func isContentValid()

A Boolean value that indicates whether the current content and attachments are valid.

func validateContent()

Performs validation of the current content and updates the state of the Post button, if appropriate.

Previewing Attachments

func loadPreviewView()

Loads a view that displays a preview of the attachments in the extension context.

Enabling Additional Configuration

func configurationItems()

Returns configuration items to display in the compose view.

func popConfigurationViewController()

Dismisses the current configuration view controller.

func pushConfigurationViewController(UIViewController!)

Presents a configuration view controller that lets the user configure the post.

func reloadConfigurationItems()

Reloads the list of configuration items.

Enabling Text Autocompletion

var autoCompletionViewController: UIViewController!

The view controller that manages an autocompletion view for suggesting common text completions while users type.

Accessing Content in the Compose View

var contentText: String!

A string that represents the text the user entered into the compose view’s text view.

var placeholder: String!

A string that’s displayed in the compose view’s text view when the text view is empty.

var textView: UITextView!

The editable text view in the compose view.