我正在使用 Xcode 10,swift 5。我有一个 tableViewController,允许用户点击、左右滑动。当向右滑动时,它会显示一个显示完成的前导按钮。当用户点击按钮时,会出现一个共享对话框并允许他们共享工作。我正在努力实现一个 UIPickerController,它允许用户为他们的项目拍照并将其嵌入到共享对话框中。
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let complete = UIContextualAction.init(style: .normal, title: "Complete") { (action, view, completion) in
let completedTxt = "Look at what I fixed, thanks to @DIY Home Repair!"
let vc = UIImagePickerController()
vc.sourceType = .camera
vc.allowsEditing = false
vc.delegate = self
self.present(vc, animated: true)
let activityController = UIActivityViewController(activityItems: [completedTxt, ], applicationActivities: nil)
self.present(activityController, animated: true, completion: nil)
completion(true) // Completion
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
picker.dismiss(animated: true)
guard let image = info[.originalImage] as? UIImage else {
print("No image found")
return
}
// print out the image size as a test
print(image.size)
}
}
该代码显示了相机并允许用户拍照,但图片无法到达任何位置,共享对话框也不会出现。当我删除 UIPickerController 的代码时,共享对话框会显示预填充的文本。