title: Swift: Updating UIPageControl from ScrollView
body: <p>I seem to be having some issues getting the UIPageControl to work.</p>
  <p>I have a ViewController that holds a ScrollView. This ScrollView loads nib files that can be swiped. See image:</p>
  <p><a href="https://i.stack.imgur.com/nh5CM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nh5CM.png" alt="enter image description here" /></a></p>
  <p>Here is the code that loads these:</p>
  <pre><code>self.addChildViewController(vc0)
  self.displayReportView.addSubview(vc0.view)
  vc0.didMoveToParentViewController(self)
          
  var frame1 = vc1.view.frame
  frame1.origin.x = self.view.frame.size.width
  vc1.view.frame = frame1
  self.addChildViewController(vc1)
  self.displayReportView.addSubview(vc1.view)
  vc1.didMoveToParentViewController(self)
  
  // And so on
  ...
  </code></pre>
  <p>This works fine as in they scroll correctly etc..</p>
  <p>Now, on the ViewController (one holding the scrollview) I added the delegate:</p>
  <pre><code>UIScrollViewDelegate
  </code></pre>
  <p>created some variables:</p>
  <pre><code> var frame: CGRect = CGRectMake(0, 0, 0, 0)
   var colors:[UIColor] = [UIColor.redColor(), UIColor.blueColor(), UIColor.greenColor(), UIColor.yellowColor()]
   var pageControl : UIPageControl = UIPageControl(frame: CGRectMake(50, 300, 200, 20))
  </code></pre>
  <p>I added some functions that are needed:</p>
  <pre><code>func configurePageControl() {
      // The total number of pages that are available is based on how many available colors we have.
      
      self.pageControl.numberOfPages = 4
      self.pageControl.currentPage = 0
      self.pageControl.tintColor = UIColor.redColor()
      self.pageControl.pageIndicatorTintColor = UIColor.blackColor()
      self.pageControl.currentPageIndicatorTintColor = UIColor.greenColor()
      self.view.addSubview(pageControl)
      
  }
  
  
  // MARK : TO CHANGE WHILE CLICKING ON PAGE CONTROL
  func changePage(sender: AnyObject) -&gt; () {
      let x = CGFloat(pageControl.currentPage) * displayReportView.frame.size.width
      displayReportView.setContentOffset(CGPointMake(x, 0), animated: true)
  }
  
  
  func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
      
      let pageNumber = round(scrollView.contentOffset.x / scrollView.frame.size.width)
      pageControl.currentPage = Int(pageNumber)
  }
  </code></pre>
  <p>Now, When I run the app the scrollview dots show, but when I swipe they do not update.</p>
  <h1>Question</h1>
  <p>How do I update the dots to reflect what view is showing?</p>
  <blockquote>
  <p>let me know if you need anything else from my code to see functionality.</p>
  </blockquote>