There is a UIViewController UIViewController with a UIViewController inserted in it, as well as a UICollectionView using AutoLayout and stretching along the edges of the UIViewController . I create cells and sections by inserts. And also I go down to the last cell.

 private func addNewMessage() { let tuplForAdd = dataSource.newMessage() if tuplForAdd.needNewSection { collectionView!.insertSections(dataSource.indexSet) } else { collectionView!.insertItems(at: [tuplForAdd.indexPath]) } collectionView.scrollToItem(at: tuplForAdd.indexPath, at: .bottom, animated: true) } 

Everything works fine until I prescribe a small contentInset

 collectionView.contentInset.top = 64 

After that, scrolling does not start immediately, but after scrolling down the height of the main window to 64. How can this be solved?

P / S The solution cannot be layout.sectionInset (as the height of the header section depends on it)

  • Look at this question at stackoverflow.com/questions/23993409/… , a solution may suit you - 0rt
  • Sorry I didn’t describe the question more qualitatively, I’ve already watched this link, the problem is that I don’t have a storyboard, I tried to change the self.automaticallyAdjustsScrollViewInsets variable in the code; But it did not give any results. - Victor Mishustin

0