title: swift UIScrollView doesnt call its "didscroll" function
body: <p>My scrollview will not call it's viewdidscroll function...
  I am pretty sure my code is "correct".
  So i am afraid there is some option somewhere in the storyboard panel. Not going to post screenshots of everything I have there. So I hope someone had the same problem.</p>
  
  <p>Any ideas?</p>
  
  <p>This is an iphone ios app in swift.</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController, UIScrollViewDelegate  {
  
      @IBOutlet var scrollView: UIScrollView!
  
  
      var imageGroup : [UIImage?] = []
      var containerViews : [UIImageView?] = []
      var containerView :UIImageView?
      var imgWidthMult : CGFloat = 2.121875
      let imageGroupCount : CGFloat?
      let containerHeight : CGFloat?
      let containerWidth : CGFloat?
      var imageCounter : Int = 0
  
  
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // 1
          imageGroup = [
              UIImage(named: "bg_001")!,
              UIImage(named: "bg_002")!,
              UIImage(named: "bg_003")!,
              UIImage(named: "bg_004")!,
              UIImage(named: "bg_005")!,
              UIImage(named: "bg_006")!,
              UIImage(named: "bg_007")!,
              UIImage(named: "bg_008")!,
              UIImage(named: "bg_009")!,
              UIImage(named: "bg_010")!,
              UIImage(named: "bg_011")!,
              UIImage(named: "bg_012")!,
              UIImage(named: "bg_013")!,
              UIImage(named: "bg_014")!,
              UIImage(named: "bg_015")!,
              UIImage(named: "bg_016")!,
              UIImage(named: "bg_017")!,
              UIImage(named: "bg_018")!,
              UIImage(named: "bg_019")!,
              UIImage(named: "bg_020")!
          ]
  
          let imageGroupCount = CGFloat(imageGroup.count)
          println(imageGroupCount)
  
  
          // 3
          for i in 0..&lt;imageGroup.count {
              containerViews.append(nil)
          }
  
          // 4
  
          let imagesScrollViewSize = UIScreen.mainScreen().applicationFrame;
          scrollView.contentSize = CGSizeMake(imagesScrollViewSize.height * imgWidthMult * CGFloat(imageGroup.count), imagesScrollViewSize.height)
  
          // 5
          let containerframe = UIScreen.mainScreen().applicationFrame;
          let containerHeight : CGFloat = containerframe.height
          let containerWidth : CGFloat = (imgWidthMult * containerHeight)
  
          loadVisibleImages()
  
          println("containerWidth")
          println(containerWidth)
          println(containerframe.size)
          println(scrollView.contentSize)
  
  
  
  
          return
      }
  
      // this loads images and should be adjusted and taken out of local scope
  
  
      func loadImage (imageCounter:Int) {
          let containerframe = UIScreen.mainScreen().applicationFrame;
          let containerHeight : CGFloat = containerframe.height
          let containerWidth : CGFloat = (imgWidthMult * containerHeight)
  
          if imageCounter &lt; 0 || imageCounter &gt;= imageGroup.count {
              // If it's outside the range of what you have to display, then do nothing
              return
          }
  
          // 1
          if let containerView = containerViews[imageCounter] {
              // Do nothing. The view is already loaded.
          } else {
              // 2
              var frame = UIScreen.mainScreen().applicationFrame;
              frame.origin.x = frame.size.height * CGFloat(imageCounter) * 2.121875
              frame.origin.y = 0.0
              frame.size = CGSize(width: containerWidth, height: containerHeight)
  
              // 3
              var newcontainerView = UIImageView(image: imageGroup[imageCounter])
              newcontainerView.contentMode = .ScaleAspectFit
              newcontainerView.frame = frame
              scrollView.addSubview(newcontainerView)
  
  
              containerViews[imageCounter] = newcontainerView
          }
  
      }
  
      func purgeImage(imageCounter:Int) {
  
          if imageCounter &lt; 0 || imageCounter &gt;= imageGroup.count {
              // If it's outside the range of what you have to display, then do nothing
              return
          }
  
          // Remove a page from the scroll view and reset the container array
          if let containerView = containerViews[imageCounter] {
              containerView.removeFromSuperview()
              containerViews[imageCounter] = nil
          }
  
      }
  
  
      func loadVisibleImages() {
  
  
          // First, determine which page is currently visible
          let containerframe = UIScreen.mainScreen().applicationFrame;
          let containerHeight : CGFloat = containerframe.height
          let containerWidth : CGFloat = (imgWidthMult * containerHeight)
          let pageWidth = (containerWidth * 2.121875)
          let imageCounter = Int(floor(scrollView.contentOffset.x / pageWidth))
  
  
          println(imageCounter)
  
          // Update the page control
  
          // Work out which pages you want to load
          let firstPage = imageCounter - 1
          let lastPage = imageCounter + 1
  
  
          // Purge anything before the first page
          for var index = 0; index &lt; firstPage; ++index {
              purgeImage(index)
          }
  
          // Load pages in our range
          for var index = firstPage; index &lt;= lastPage; ++index {
              loadImage(index)
          }
  
          // Purge anything after the last page
          for var index = lastPage+1; index &lt; imageGroup.count; ++index {
              purgeImage(index)
          }
          println("loadVisibleImages")
      }
  
  
  
  
  
      func scrollViewDidScroll(scrollView: UIScrollView) {
          // Load the pages that are now on screen
          println("did scroll")
          loadVisibleImages()
          println("did scroll")
  
      }
  
  
  
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
  }
  </code></pre>