3

I know how to create an iOS share extension, but what I can't figure out is if there is a way to make it fullscreen such as an Action extension?

Pinterest seem to do this but I'm not sure how.

The docs for an Action extension say to use:

          <key>NSExtensionActionWantsFullScreenPresentation</key>
    <true/>

In the plist file for the extension but this doesn't seem to have an effect in the Share extension?

Is there anyway to accomplish this?

TommyBs
  • 9,354
  • 4
  • 34
  • 65

2 Answers2

5

You can get ideas from there iOS Full Screen Share Extension and you can find the updated syntax for the code snippets below which is compatible with Swift 3 and Swift 4

EntryViewController

import UIKit

@objc(EntryViewController)

class EntryViewController : UINavigationController {

    override init(rootViewController: UIViewController) {
        super.init(rootViewController: ShareViewController())
    }

    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)!
    }

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.view.transform = CGAffineTransform(translationX: 0, y: self.view.frame.size.height)
        UIView.animate(withDuration: 0.3, animations: { () -> Void in
            self.view.transform = .identity
        })
    }

}

ShareViewController

import UIKit
import Social

class ShareViewController: SLComposeServiceViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.backgroundColor = UIColor.white
        self.navigationItem.title = "Share"

        self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: Selector(("cancelButtonTapped:")))
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .save, target: self, action: Selector(("saveButtonTapped:")))
    }

    func saveButtonTapped(sender: UIBarButtonItem) {
        self.hideExtensionWithCompletionHandler(completion: { (Bool) -> Void in
        self.extensionContext!.completeRequest(returningItems: nil, completionHandler: nil)
        })
    }

    func cancelButtonTapped(sender: UIBarButtonItem) {
        self.hideExtensionWithCompletionHandler(completion: { (Bool) -> Void in
        self.extensionContext!.cancelRequest(withError: NSError())
        })
    }

    func hideExtensionWithCompletionHandler(completion: @escaping (Bool) -> Void) {
        UIView.animate(withDuration: 0.3, animations: { 
        self.navigationController!.view.transform = CGAffineTransform(translationX: 0, y: self.navigationController!.view.frame.size.height)
        }, completion: completion)
    }

}
abdullahselek
  • 7,893
  • 3
  • 50
  • 40
1

I have solved full screen share extension.

It's simple.

You add NSExtensionActionWantsFullScreenPresentation and set TRUE under NSExtension of extension app's info.plist

https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/AppExtensionKeys.html#//apple_ref/doc/uid/TP40014212-SW35

enter image description here

dobiho
  • 1,025
  • 1
  • 11
  • 22