Class

SLComposeServiceViewController

A view controller that you present from your share app extension, allowing the user to compose social media posts.

Declaration

iOS, Mac Catalyst
@interface SLComposeServiceViewController : UIViewController
macOS
@interface SLComposeServiceViewController : NSViewController

Overview

The SLComposeServiceViewController class provides a standard compose view, and you can present it for social sharing extensions on iOS and macOS. 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.

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

Topics

Configuring the Post Details

- configurationItems

Returns configuration items to display in the compose view.

SLComposeSheetConfigurationItem

An object that provides additional configuration details to use when configuring a composition interface.

- reloadConfigurationItems

Reloads the list of configuration items.

Managing the Contents of the Post

contentText

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

placeholder

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

textView

The editable text view in the compose view.

Presenting the View Controller

- pushConfigurationViewController:

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

- popConfigurationViewController

Dismisses the current configuration view controller.

Responding to Lifecycle Events

- presentationAnimationDidFinish

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

- didSelectCancel

Sent to the compose view after the cancel animation finishes.

- didSelectPost

Sent to the compose view after the post animation finishes.

Canceling a Post

- cancel

Starts the animated dismissal of the compose view.

Validating Content

charactersRemaining

The number of characters remaining in a custom character limit.

- isContentValid

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

- validateContent

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

Previewing Attachments

- loadPreviewView

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

Enabling Text Autocompletion

autoCompletionViewController

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

See Also

Composition Interfaces

SLComposeViewController

A view controller that allows the user to compose social media posts.