我已经实现了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}
时,我假设的尺寸是分辨率。如果这是真的,我认为图像可能太大而无法分享。如果这是正确的,
有没有办法降低图像的分辨率?