J'utilise UICollectionView
, sur le défilement à une partie spécifique de UICollectionView
j'écris une extension sur UICollectionView
qui fonctionne très bien sur l'iPhone 6 & également sur simulateur, mais dans l'application iPhone 5 se est écrasé debugger mais ne peut pas trouver quel est le problème.App se est écrasé sur `layoutAttributesForSupplementaryElement`
Voici mon code
extension UICollectionView {
func scrollToIndexpathByShowingHeader(_ indexPath: IndexPath) {
let sections = self.numberOfSections
if indexPath.section <= sections {
let attributes = layoutAttributesForSupplementaryElement(ofKind: UICollectionElementKindSectionHeader, at: indexPath)
let topOfHeader = CGPoint(x: 0, y: attributes!.frame.origin.y - self.contentInset.top)
self.setContentOffset(topOfHeader, animated:false)
}
}
}
sur let attributes = layoutAttributesForSupplementaryElement(ofKind: UICollectionElementKindSectionHeader, at: indexPath)
mon application se est écrasé et la raison de l'accident est la suivante:
reason: 'no UICollectionViewLayoutAttributes instance for -layoutAttributesForSupplementaryElementOfKind: UICollectionElementKindSectionHeader at path <NSIndexPath: 0x1564e0b0> {length = 2, path = 18 - 1}'
bien vouloir me faire savoir ce qui est problème et comment résoudre ce Merci d'avance :-)
Je ne peux pas comprendre cela. veuillez m'expliquer plus. @Jaydeep –
La réponse précédente est correcte 'layoutAttributesForItem (at: indexPath)' veuillez ré-éditer pour que je puisse aacept –
@asimabbasi, Strange :) – Jaydeep