【发布时间】:2021-12-29 22:01:00
【问题描述】:
我有一个tableView 和viewController。我需要使用图像选择器添加一张照片(我已经这样做了),然后我需要将其与描述一起保存为我的 tableView 中的新帖子。最好的方法是什么?
我已经找到了如何在tableView 中将文本添加为新单元格的信息,但这不是我想要的。
这是我的代码
@IBAction func photoButton(_ sender: UIButton){
let vc = UIImagePickerController()
vc.sourceType = .photoLibrary //PHPpicker
vc.delegate = self
vc.allowsEditing = true
present(vc,animated: true)
}
@IBAction func saveButtonPressed(_ sender: UIButton){
}
extension NewPostScreenController : UIImagePickerControllerDelegate , UINavigationControllerDelegate {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
UIImagePickerController.InfoKey(rawValue: "")
if let image = info[UIImagePickerController.InfoKey(rawValue: "UIImagePickerControllerEditedImage")] as? UIImage {
ChangeImage.image = image
}
picker.dismiss(animated: true, completion: nil)
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
picker.dismiss(animated: true, completion: nil)
}
}
我应该在saveButtonPressed 中添加什么?
【问题讨论】:
标签: ios swift uiimagepickercontroller