0

I have implemented a UIActivityController that retrieves an image from UIPickerViewController. I am able to successfully share text and image via text message but I cannot share the same through Facebook or messenger.

 override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
            let complete = UIContextualAction.init(style: .normal, title: "Complete") { (action, view, completion) in

                if UIImagePickerController.isSourceTypeAvailable(.camera) {
                    self.picker.allowsEditing = false
                    self.picker.sourceType = UIImagePickerController.SourceType.camera
                    self.picker.cameraCaptureMode = .photo
                    self.picker.modalPresentationStyle = .fullScreen
                    self.present(self.picker,animated: true,completion: nil)
                } else {
                    self.noCamera()
                }

        }
                //        complete.image = //... Add an image
                complete.backgroundColor = #colorLiteral(red: 0.3411764801, green: 0.6235294342, blue: 0.1686274558, alpha: 1)
                let action = UISwipeActionsConfiguration.init(actions: [complete])
                action.performsFirstActionWithFullSwipe = true //... Full swipe support
                return action
}

 func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {

    guard let myImageView = info[.originalImage] as? UIImage else {
        return
    }
    print(myImageView)

    if myImageView != nil {
        self.dismiss(animated: true, completion: nil)
        let activityController = UIActivityViewController(activityItems: [self.completedTxt, myImageView as Any], applicationActivities: nil)

        present(activityController, animated: true, completion: nil)

    }else {
        return
    }
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
    dismiss(animated: true, completion: nil)
}

When I print(myImageView) the size is {3024, 4032} which I am assuming is the resolution. If this is true I think the image may be too large to share. If this is correct,

is there a way to reduce the resolution of the image?

Hitesh Surani
  • 12,733
  • 6
  • 54
  • 65
  • No there is no issue of resolution , Your question is similar to mine https://stackoverflow.com/questions/50486049/uiactivityviewcontroller-facebook-sharing-url-image-and-url-text-not-working . Answer is you can't share text + image. You can either share image or text – Prashant Tukadiya May 08 '19 at 05:00
  • When I remove the text the image still causes the facebook post dialogue to crash. When I use text message app the image is there. Any idea why? –  May 08 '19 at 13:18

0 Answers0