title: Swift 3 - UICollectionview Problems on iOS 11.2
body: <p>I have two problems with <code>UICollectionView</code>. Following are the scenarios:</p>
  
  <blockquote>
    <p><strong>Problem 1</strong></p>
  </blockquote>
  
  <p>I have an app that is created in Xcode 8. It's build on iOS 10.3 simulator and everything was good. But when I tried on my device with iOS 11.2, I have a problem with the <code>UICollectionView</code>. When a new data comes, it should be appears on bottom (that's what I want and have done on iOS 10.3). But iOS 11.2 makes it to scroll to top when the new data comes on bottom.</p>
  
  <blockquote>
    <p><strong>Problem 2</strong></p>
  </blockquote>
  
  <p>Then I have migrated from Xcode 8 to Xcode 9.2 because Xcode 8 has no direct support to iOS 11. But now on Xcode 9.2 iOS 11.2 simulator, I can't scroll the collectionview clearly and then it breaks in <code>UIAppDelegate</code> with <code>Thread 1: signal SIGABRT.</code> </p>
  
  <p>As long as I know, this kind of error will appear whenever I have a disconnected outlet. But I'm pretty sure all of my outlets have connected. </p>
  
  <pre><code>import UIKit
  
  class cvViewController: UIViewController, UICollectionViewDataSource, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UICollectionViewDelegate {
  
  @IBOutlet var collectionView: UICollectionView!
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      collectionView.delegate = self
  
      collectionView.register(UINib.init(nibName: "Cell", bundle: nil), forCellWithReuseIdentifier: "Cell")
      if let flowLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
          flowLayout.estimatedItemSize = CGSize(width: 1,height: 1)
      }
  
      loadAPI(Page: 1) //display data
  
      scrollDownButton.clipsToBounds = true
      scrollDownButton.layer.cornerRadius = 15
  
      sendButton.addTarget(self, action: #selector(cvViewController.sendMessage), for: .touchDown) //push a new data
  
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  override func viewDidAppear(_ animated: Bool) {
      super.viewDidAppear(animated)
      scheduledTimerWithTimeInterval()
      if move == 0{
          scrollToBottomAnimated(animated: true)
      }
  
      scrollDownButton.addTarget(self, action: #selector(cvchatViewController.scrollToBottomAnimated), for: .touchDown) //it will display last item on screen
  
      flowLayout.scrollDirection = .vertical
  
  }
  
  func scrollToBottomAnimated(animated: Bool) {
      guard self.collectionView.numberOfSections &gt; 0 else{
          return
      }
  
      let items = self.collectionView.numberOfItems(inSection: 0)
      if items == 0 { return }
  
      let collectionViewContentHeight = self.collectionView.collectionViewLayout.collectionViewContentSize.height
      let isContentTooSmall: Bool = (collectionViewContentHeight &lt; self.collectionView.bounds.size.height)
  
      if isContentTooSmall {
          self.collectionView.scrollRectToVisible(CGRect(x: 0, y: collectionViewContentHeight - 1, width: 1, height: 1), animated: animated)
          return
      }
  
      self.collectionView.scrollToItem(at: NSIndexPath(item: items - 1, section: 0) as IndexPath, at: .bottom, animated: animated)
  }
  
  
  public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      return chatPages.count
  }
  
  public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! Cell
  
       cell.vNameLabel.text = chatPages[indexPath.row].username
       cell.VCDateLabel.text = chatPages[indexPath.row].timeSent
       cell.vImageSend.image = UIImage(named: "1x1px")
  
      return cell
  }
  
  
  func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -&gt; Bool {
      return true
  }
  </code></pre>
  
  <p>Can anyone help me to solve this? I am just a beginner on Swift by the way. I appreciate all of your responses. Thanks!</p>
  
  <p>NB: I've simplicize the code because the actual code is really complicated.</p>