1

I am having difficulty getting UICollectionView Content Insets Adjustment Behavior setting to work. It appears to be modifying the location of 'ghost' ReusableView instead of my header view. In this screenshot the ghost view is selected, the header view I'm trying to control is green (its bg color).

I have tried using both the story board and programatic options, both are moving the position of the ghost view instead of my visible view. I cannot find where these ghost views are being generated nor can I see them in storyboard.

screenshot of ghost views

Here is my reusable view function:

override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
    if(kind == "UICollectionElementKindSectionHeader"){
        let view = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "questionHeader", for: indexPath) as! QuestionheaderCollectionReusableView
        if(self.mode == .Test){
            view.scoreRing.alpha = 0.5
            view.scoreRing.style = .ontop
        }else{
            view.updateScore(session: QKSession.default)
        }
        if((activeQuestion) != nil){
            view.questionLabel.text = activeQuestion?.question
            view.updateProgress(session: QKSession.default, question: activeQuestion!)
        }else{
            view.questionLabel.text = "Please select a MQF"
        }

        return view
    }else{
        let view = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "questionFooter", for: indexPath) as! QuestionFooterCollectionReusableView
        return view
    }
}

Has anyone else seen anything like this?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Umbo LLC
  • 11
  • 1
  • Unrelated to your issue but replace `if(kind == "UICollectionElementKindSectionHeader"){` with `if kind == UICollectionView.elementKindSectionHeader {`. Don't needlessly hardcode undocumented strings. – rmaddy Jun 02 '19 at 23:15
  • @rmaddy good point – Umbo LLC Jun 03 '19 at 00:26

0 Answers0