hi, when i done challenge, appear the bug with one and the same cell, it stay big after scrolling to bottom and back to top.
i don’t understood what to do with this bug.
@vladyslavv8 As the error describes it pertains to the fact that in the subclass TimbreLayout the layout attributes aren’t being copied.
This fixed it for me:
override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
var cache = [UICollectionViewLayoutAttributes]()
if let layoutAttributes = super.layoutAttributesForElementsInRect(rect) as [UICollectionViewLayoutAttributes]?{
for attributes in layoutAttributes {
let att = attributes.copy() as! UICollectionViewLayoutAttributes
let frame = att.frame
att.transform = CGAffineTransformMakeRotation(degreesToRadians(-14))
att.frame = CGRectInset(frame, 12, 0)
cache.append(att)
}
}
return cache
}
2 Likes
rcritz
October 6, 2016, 8:41pm
4
A simpler solution is just to adjust the line that calls super
, like so:
let layoutAttributes = super.layoutAttributesForElement(in: rect)!.map
{ $0.copy() as! UICollectionViewLayoutAttributes }
The downcast in the closure is required because copy()
is a method on NSObject
that returns an Any
.
gsharm1
January 20, 2019, 10:02pm
5
@raywenderlich there’s a weird 1 minute of black screen at the end of part 12 of this course.
@gsharm1 Thank you for the heads up - much appreciated! I will let the video team know. Thanks again!
1 Like