无法将图片分享到Facebook和Messenger

时间:2019-05-08 04:55:50

标签: ios swift uiactivityviewcontroller facebook-share uipickerviewcontroller

我实现了一个UIActivityController,它从UIPickerViewController检索图像。我能够通过短信成功共享文本和图像,但无法通过Facebook或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)
}

当我打印(myImageView)时,尺寸为{3024, 4032},我假设它是分辨率。如果是这样,我认为图像可能太大而无法共享。如果正确,

是否有降低图像分辨率的方法?

0 个答案:

没有答案