Search code examples
iosobjective-ciphoneios-app-extensionios-extensions

How to present an action extension in an action sheet rather than full-screen modal view?


According to the documentation, action extensions appear in an action sheet or full-screen modal view. But for IPhone portrait orientation it is always fullscreen by default. How can I present the action extension view in an action sheet for the iPhone portrait orientation?

I have tried setPreferredContentSize and NSExtensionActionWantsFullScreenPresentation. Both seems to have no effect in iPhone portrait orientation.


Solution

  • There's no way for an action extension to be non-fullscreen on iPhone.*

    The alternative presentation when NSExtensionActionWantsFullScreenPresentation is false is equivalent to UIModalPresentationFormSheet. Form Sheet presentation is non-fullscreen only on iPad — it's the presentation style you see for things like composing a new message in Mail, or viewing app details in the App Store. You can still choose form sheet presentation on iPhone,* but it behaves equivalent to fullscreen.

    * Well, sort of. It's not actually iPhone vs iPad that makes form sheet be fullscreen, but horizontally compact vs horizontally regular size class. Which means that form sheet is non-fullscreen on iPhone 6/6s Plus in landscape orientation, but not in portrait orientation or on other iPhone models.