Ios UICollection内容插入调整行为修改';鬼';可重用视图,而不是我的标题
我很难让UICollectionView内容插入调整行为设置正常工作。它似乎在修改“ghost”ReusableView的位置,而不是我的标题视图。在这个屏幕截图中,选择了重影视图,我试图控制的标题视图是绿色的(它的背景色) 我尝试使用故事板和编程选项,两者都在移动重影视图的位置,而不是我的可见视图。我找不到这些重影视图的生成位置,也无法在情节提要中看到它们 以下是我的可重用视图函数:Ios UICollection内容插入调整行为修改';鬼';可重用视图,而不是我的标题,ios,swift,uicollectionview,uicollectionviewflowlayout,Ios,Swift,Uicollectionview,Uicollectionviewflowlayout,我很难让UICollectionView内容插入调整行为设置正常工作。它似乎在修改“ghost”ReusableView的位置,而不是我的标题视图。在这个屏幕截图中,选择了重影视图,我试图控制的标题视图是绿色的(它的背景色) 我尝试使用故事板和编程选项,两者都在移动重影视图的位置,而不是我的可见视图。我找不到这些重影视图的生成位置,也无法在情节提要中看到它们 以下是我的可重用视图函数: override func collectionView(_ collectionView: UIColle
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
}
}
其他人见过类似的情况吗?与您的问题无关,但将
if(kind==“UICollectionElementKindSectionHeader”){
替换为if kind==UICollectionView.elementKindSectionHeader{
。不要对未记录的字符串进行不必要的硬编码。@rmaddy很好,与您的问题无关,但替换if(kind==“UICollectionElementKindSectionHeader”){
如果种类==UICollectionView.elementKindSectionHeader{,则使用。不要对未记录的字符串进行不必要的硬编码。@rmaddy很好