CardParts Cannot be shared across states
muzoman opened this issue · 0 comments
If a CardPart is created and then used in multiple calls to setupCardParts forState then upon first display the shared CardPart is not displayed.
I amended the example StateCardController thus:
`
override func viewDidLoad() {
super.viewDidLoad()
self.state = .empty
let sharedPart = CardPartTextView(type: .normal)
sharedPart.text = "Shared Card Part"
let textPart = CardPartTextView(type: .normal)
textPart.text = "Empty State"
let loadingCardPart = CardPartTextView(type: .normal)
loadingCardPart.text = "I am a loading state part"
let customCardPart = CardPartTextView(type: .normal)
customCardPart.text = "I am a custom state that you can make!"
setupCardParts([customCardPart, sharedPart], forState: .custom(customStateKey))
setupCardParts([textPart, sharedPart], forState: .empty)
setupCardParts([loadingCardPart, sharedPart], forState: .loading)
}`
If the state is changed then the card parts are then correctly displayed but there's an XCode warning triggered:
CardParts_Example[20068:4559504] [Warning] Warning once only: Detected a case where constraints ambiguously suggest a size of zero for a collection view cell's content view. We're considering the collapse unintentional and using standard size instead. Cell: <CardParts.CardCell: 0x7fa827c48b10; baseClass = UICollectionViewCell; frame = (10 0; 394 0); layer = <CALayer: 0x6000029e8740>>