UIActivityViewController ignoring excludedActivityTypes

306 views Asked by At

I need to exclude .saveToCameraRoll from a UIActivityViewController but it is ignoring excludedActivityTypes.

activityVC = UIActivityViewController(activityItems: [imgUrl], applicationActivities: activities)
activityVC!.excludedActivityTypes = [.saveToCameraRoll]

I also tried creating a "custom" UIActivty and exclude it:

let saveToCameraRollActivity = UIActivity.ActivityType.init(rawValue: "\(UIActivity.ActivityType.saveToCameraRoll.rawValue)")
activityVC!.excludedActivityTypes = [saveToCameraRollActivity]

Both ways have no effect, the Save Image option is still displayed. What is the point of being able to exclude activity types if they are ignored?

The header says:

// default is nil. activity types listed will not be displayed
excludedActivityTypes: [UIActivity.ActivityType]? 

I need to use my own Save Image because standard one is not respecting the file name (even though it is shown with the file icon and I am using a URL).

1

There are 1 answers

1
keyur kathrotiya On

I am using this function and hide "save video" button :--

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

        activityViewController.excludedActivityTypes = [UIActivity.ActivityType.copyToPasteboard, UIActivity.ActivityType.saveToCameraRoll]

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