Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Brayden Kness
12,492 PointsUICollectionViewCell Unwanted Reusing
In an app that I am building there is a screen where the user selects from a variety of options within a collection view. When one of the cells is tapped it gets a blue border to show it has been tapped. However, when the user scrolls down there are other cells with the same blue border that have not been tapped. I am assuming this is because the cells are reused but I am not sure. How can I fix this?
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let cell = collectionView.cellForItemAtIndexPath(indexPath)!
cell.layer.borderWidth = 4.0
cell.layer.borderColor = self.view.tintColor.CGColor!
}
Brayden Kness
12,492 PointsJust added them Joshua Kidd
Joshua Kidd
3,411 PointsJoshua Kidd
3,411 PointsDo you have any code examples that you would be able to share?