-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
recommendations-iPad-fix #1369
recommendations-iPad-fix #1369
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,7 +1,3 @@ | ||||||||||||||||||||||||||
// | ||||||||||||||||||||||||||
// Copyright © FINN.no AS, Inc. All rights reserved. | ||||||||||||||||||||||||||
// | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
import UIKit | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
protocol AdRecommendationsGridViewLayoutDelegate: AnyObject { | ||||||||||||||||||||||||||
|
@@ -75,7 +71,7 @@ class AdRecommendationsGridViewLayout: UICollectionViewLayout { | |||||||||||||||||||||||||
override func prepare() { | ||||||||||||||||||||||||||
super.prepare() | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
itemAttributes = [UICollectionViewLayoutAttributes]() | ||||||||||||||||||||||||||
itemAttributes.removeAll() | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
guard let collectionView = collectionView else { | ||||||||||||||||||||||||||
return | ||||||||||||||||||||||||||
|
@@ -122,7 +118,13 @@ class AdRecommendationsGridViewLayout: UICollectionViewLayout { | |||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? { | ||||||||||||||||||||||||||
return itemAttributes[indexPath.row] | ||||||||||||||||||||||||||
guard itemAttributes.indices.contains(indexPath.row) | ||||||||||||||||||||||||||
else { return nil } | ||||||||||||||||||||||||||
if itemAttributes[indexPath.row].representedElementCategory == .cell { | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix: for some reason, on iPads when launching the app from background this method is called with indexPath.row == 0 which would cause a crash, since at index 0 in the array we have a layout attribute for a header and not for a cell |
||||||||||||||||||||||||||
return itemAttributes[indexPath.row] | ||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
Comment on lines
+121
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
override var collectionViewContentSize: CGSize { | ||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since collectionView is a mutable var, it's best to re-create the layout