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?