title: ImageView inside of ScrollView showing wrong picture
body: <p>I have a scroll view that has an image view embedded into it. The user clicks the "Take Photo" button, takes a picture, and then those photos are stored in an array and then displayed on the scrollable imageView. My issue is that after the didFinishSelectingMedia is called and the camera closes, the imageView always shows the first image in the array. I want the imageView to show the most recent image added to the array and scroll backward through the images until the user comes to the first image in the array. How do I make this happen?</p>
  
  <p>Btw: Idk if this is even plausible, but I tried reversing the for loop and that didn't work.</p>
  
  <p>I'm a new programmer, so please explain your answers.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
  
      @IBOutlet weak var scrollImageView: UIScrollView!
  
  
      var imageTaken: [UIImage] = []
      var imagePicker = UIImagePickerController()
  
  
      override func viewDidLoad() {
  
          super.viewDidLoad()
  
          scrollImageView.frame = scrollImageView.frame
  
      }
  
  
  
      @IBAction func takePhotoButton(_ sender: Any) {
  
          imagePicker = UIImagePickerController()
          imagePicker.delegate = self
          imagePicker.sourceType = .camera
  
          present(imagePicker, animated: true, completion: nil)
  
      }
  
      func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
          imageTaken.append((info[.originalImage] as? UIImage)!)
          imagePicker.dismiss(animated: true, completion: nil)
  
  
          for i in 0..&lt;imageTaken.count {
              let imageView = UIImageView()
              imageView.image = imageTaken[i]
              imageView.contentMode = .scaleAspectFit
              let xPosition = self.scrollImageView.frame.width * CGFloat(i)
  
              imageView.frame = CGRect(x: xPosition, y: 0, width: self.scrollImageView.frame.width, height: self.scrollImageView.frame.height)
  
              scrollImageView.contentSize.width = scrollImageView.frame.width * CGFloat(i + 1)
              scrollImageView.addSubview(imageView)
  
          }
  
  
      }
  
  }
  </code></pre>