Swift 4
Измените Contentmode изображения ImageView на aspectfit
или aspectfill
на сюжете и отметьте Клипы, чтобы ограничить.
Вы также можете сделать это программно
cell.documentImage?.clipsToBounds = true
cell.documentImage?.contentMode = .scaleAspectFit
Вот полный код вашего метода.
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
let path = IndexPath(row: self.selectedCell.row, section: 0)
let cell = Tableview.cellForRow(at: path) as! CustomTableviewCell
cell.documentImage?.image = pickedImage
cell.documentImage?.clipsToBounds = true //clips out the image out of the cell
cell.documentImage?.contentMode = .scaleAspectFit //fits the streacth view in image
cell.documentImage?.frame = CGRect()
}
Tableview.reloadData()
picker.dismiss(animated: true, completion: nil)
}