In the application, the user can attach several files to the form. For this, I used the UIImagePickerController :
@IBAction func AttachNewFileClick(_ sender: Any) { let imagePicker = UIImagePickerController() imagePicker.delegate = self imagePicker.sourceType = .photoLibrary imagePicker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .photoLibrary)! present(imagePicker, animated: true, completion: nil) } func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { let imageUrl:URL = info["UIImagePickerControllerImageURL"] as! URL let mime:String = info["UIImagePickerControllerMediaType"] as! String let original:UIImage = info["UIImagePickerControllerOriginalImage"] as! UIImage let newAttachedFile = AttachedPhoto() newAttachedFile.setImageSource(url: imageUrl, name: imageUrl.lastPathComponent, mime: mime, image: original) AttachedFilesStack.addSubview(newAttachedFile) filePreview.append(newAttachedFile) picker.dismiss(animated: true, completion: nil) } Attached files are objects of class AttachedPhoto . It has a UIImageView and a UIButton to unpin an attachment. All the previews of the attached photos lie in AttachedFilesStack which is an object of the OAStackView class (min SDK 8.2, so I cannot use the embedded StackView, they need min SDK 9).
The first attachment is shown correctly, but subsequent ones instead of being located side by side overlap the first one What can I do to correct this behavior?
No investment:
Attached first photo:
Attached the second (with the first everything is in order, it is simply blocked by the second):


