0

I make a SLComposeViewController everything works fine until I want to share my Image, there's alot things to click including " import to whatsapp, import to Instagram " and etc.

If I clicked on this my apps will stuck. So I want to exclude all this import things. The question is how can I ? because in UIActivityType. there's no choice of exclude this module

func shareQR(){        
    if filename != nil {
        let imageToShare = [ filename ]
        let activityViewController = UIActivityViewController(activityItems: imageToShare, applicationActivities: nil)
        activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash

        activityViewController.excludedActivityTypes = [ UIActivityType.airDrop ]

        self.present(activityViewController, animated: true, completion: nil) 
    } 
}

EDIT IMAGE

enter image description here

There's bunch of thing that useless here like "Copy to" & "Import with" I just need like "Instagram" "Whatsapp" and etc.

I need to exclude all of this because it's useless and if this icon clicked will freeze my apps.

StevenTan
  • 275
  • 1
  • 5
  • 20
  • Can you elaborate more ? – Jack May 29 '17 at 07:08
  • as you told 'freezing app' you need to figure out your code.It's working fine(dismissing) as i tested. – Jack May 29 '17 at 07:42
  • well that's a second problem, the main problem is I don't need that tho showed up. how to exclude that @Jack – StevenTan May 29 '17 at 08:11
  • Can you put some of sharing code ? – Jack May 29 '17 at 08:12
  • what part of specific code sir ? isn't the code I give already call the SLComposerViewController. nothing else – StevenTan May 29 '17 at 08:14
  • After `UIActivityViewController` open, when you tap on any activity items `UIActivityViewController ` will dismiss(`dismissViewController(animated:true)`) hence perhaps you need to check with your current as well as previous viewcontroller. – Jack May 29 '17 at 08:19
  • Is it needed ? because I dont have any of that like `(dismissViewController(animated:true)` maybe I'm missing something here, because the only code about UIActivityViewController only that code – StevenTan May 29 '17 at 08:22

1 Answers1

0

As of iOS API of UIActivityViewController

@available(iOS 6.0, *)
open class UIActivityViewController : UIViewController {


    public init(activityItems: [Any], applicationActivities: [UIActivity]?)


    @available(iOS, introduced: 6.0, deprecated: 8.0, message: "Use completionWithItemsHandler instead.")
    open var completionHandler: UIKit.UIActivityViewControllerCompletionHandler? // set to nil after call

    @available(iOS 8.0, *)
    open var completionWithItemsHandler: UIKit.UIActivityViewControllerCompletionWithItemsHandler? // set to nil after call


    open var excludedActivityTypes: [UIActivityType]? // default is nil. activity types listed will not be displayed
}

There is no extra methods for excluding share activities (Which is presented on first row), Only user have choice to enable/disable by clicking More on first row then disable switch.

Jack
  • 13,571
  • 6
  • 76
  • 98
  • Only with by clicking More ? nothing else ? I know there's a option from `More` but not all people want to go through that. thats why – StevenTan May 29 '17 at 08:12
  • Nothing. Only user have choice to disable that. Because we really don't know which apps are installed on iPhone – Jack May 29 '17 at 08:14