-
Notifications
You must be signed in to change notification settings - Fork 351
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
Having trouble with Cube Animator w/ programmatic cells #61
Comments
I am also able to reproduce this by taking the sample project, removing the prototype cell, and replacing it with my own cell. As soon as I use the custom cell, like the one above, the layout breaks. Any idea what could be so different between the storyboard and programmatic setup? |
The only thing I can think of is the clipsToBounds settings on either the cell or the contentView. Can you upload a sample project to reproduce this? |
Hi @KelvinJin , thank you for the quick response. I've attached a project that demonstrates this. All I've done is take the sample project from the repo, remove the prototype cell from the storyboard, and modified it slightly to work programmatically instead. |
Hi @KelvinJin Please confirm |
@GalCohen @kazuteru Sorry for the late reply guys. This issue has been giving me some hard time 😢 What I found out is that I broke this with the latest update. I can't figure out what exactly are different between programmatically created cell and the one created in Interface Builder. But my update fixed similar issue that's happening on the IB created while introduced the issue to the programmatic one 🤯 Now the proper way to fix this is to figure out what are the differences and try to workaround both cases at the same time. At the mean time, please either
Again, thanks for reporting this issue!
|
I spent a few hours on this with no luck. Thanks for taking the time to investigate and suggesting some fixes. Really appreciate the work! |
use autoLayout
|
@KelvinJin else if attributes.scrollDirection == .horizontal {
let rotateAngle = totalAngle * position
let anchorPoint = CGPoint(x: position > 0 ? 0 : 1, y: 0.5)
// As soon as we changed anchor point, we'll need to either update frame/position
// or transform to offset the position change. frame doesn't work for iOS 14 any
// more so we'll use transform.
let anchorPointOffsetValue = contentView.layer.bounds.width / 2
let anchorPointOffset = position > 0 ? -anchorPointOffsetValue : anchorPointOffsetValue
var transform = CATransform3DMakeTranslation(anchorPointOffset, 0, 0)
contentView.layer.anchorPoint = anchorPoint
if #available(iOS 14, *) {
if contentView.translatesAutoresizingMaskIntoConstraints == true {
// not use transformX/Y
transform = CATransform3DMakeTranslation(0, 0, 0)
// reset origin
var frame = attributes.frame
frame.origin = .zero
contentView.frame = frame
}
}
transform.m34 = perspective
transform = CATransform3DRotate(transform, rotateAngle, 0, 1, 0)
contentView.layer.transform = transform
} |
Works for most devices, but not work for iPhone 7 Plus(iOS 13.6), or iPhone 11 sometimes. |
try to add checking for rotateAngle in this place: if abs(position) >= 1 || rotateAngle == 0 { |
@HimmaHorde you saved my day🥳, thank you! |
Hi.
The layout looks broken when using a cell programmatically. What am I missing? What could be different between the configuration of the cell in the Sample project in the storyboard and my own?
I narrowed the problem down to cell configuration because if I copy the Sample project's storyboard and viewControllers, I am about to successfully display and scroll the collectionview. As soon as I replace the Sample cell with my own, it fails.
I tore down the cell to the bare minimum
and still, I get something like:
I'm on v 1.10, using SwiftPM, testing on iPhone SE Simulator iOS 13.5 And 14.
I'm just trying to test out a full screen collectionview exactly like the sample project, only programmatic, and using my own cell.
The text was updated successfully, but these errors were encountered: