2017-11-07 4 views
0

IGListKit으로 구현 된 UICollectionView의 맨 아래로 스크롤하려고합니다. 내 방법 :IGListKit을 사용하여 섹션 맨 아래로 스크롤하는 방법

func scrollToBottom(animated: Bool = true) { 
    if let last = self.adapter.objects().last { 
     self.adapter.scroll(
      to: last, 
      supplementaryKinds: nil, 
      scrollDirection: UICollectionViewScrollDirection.vertical, 
      scrollPosition: UICollectionViewScrollPosition.bottom, 
      animated: animated) 
    } 
} 

이것은 마지막 항목까지 스크롤하지만 마지막 개체의 맨 아래로 스크롤하지 않았습니다.

실제 결과 :

The actual result

원하는 결과 :

The desired result

어떤 제안이 어떻게 내 원하는 결과를 얻으려면?

답변

1

는 기본 UICollectionView 및 setContentOffset 방법을 사용하여 그것을 해결

func scrollToBottom(animated: Bool = true) { 
    let bottomOffset = CGPoint(
     x: 0, 
     y: self.collectionView.contentSize.height 
      - self.collectionView.bounds.size.height 
      + self.collectionView.contentInset.bottom) 
    self.collectionView.setContentOffset(bottomOffset, animated: animated) 
} 
관련 문제