The decoration view is not deleted after deleting the entire line as a collection

I added a decorative look to the UICollectionViewsubclass path UICollectionViewFlowLayout. I am m placing decoration view under each row in collection view. Itworking fine. There are types of scenery. But the problem is that design elements are not removed from the collection view after deleting one whole line of elements. But the header and footer are correctly moved, and I did not process them. I do not know where to remove the jewelry after removal. Help me. My calculation of the decorative look is prepareLayoutgood where the decor and frame are correct.

enter image description hereenter image description here

(Fig. 1) Before removal (Fig. 2) After removal

+5
source share
4 answers

. . (/ ) . . , View.

prepareLayout

 /// Collection view is not removing the added decoraion views afeter deletion. Remove yourself to fix that
for (UIView *view in self.collectionView.subviews) {
    if ([view isKindOfClass:[DecorationView class]])
    {
        [view removeFromSuperview];
    }

}
+2

iOS 7, -indexPathsToInsertForDecorationViewOfKind: -indexPathsToDeleteForDecorationViewOfKind: , / , .

+1

. .

- , . , . , , . .

, , , , .

, :

  collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView

,

layoutAttributesForElementsInRect(rect: CGRect) -> [AnyObject]? 

layoutAttributesForSupplementaryViewOfKind(elementKind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes! 

.

, , , , , .

0

UICollectionViewLayout / :

func prepare(forCollectionViewUpdates updateItems: [UICollectionViewUpdateItem])

func indexPathsToDeleteForSupplementaryView(ofKind elementKind: String) -> [IndexPath]

func indexPathsToInsertForDecorationView(ofKind elementKind: String) -> [IndexPath]

, , document

0

All Articles