Dynamic collectionView in UITableViewCell(1)
As described in my previous post, I'm using dynamic collectionView in UITableViewCell
for a view like this:
While it works great on devices with other devices, when a tag string is very long, the app enters an endless loop while printing error like crazy in iPhone 5s.
The behavior of the UICollectionViewFlowLayout is not defined because:
the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values.
Please check the values returned by the delegate.
The relevant UICollectionViewFlowLayout instance is <UICollectionViewLeftAlignedLayout: 0x7fbf05c5ddb0>, and it is attached to <UICollectionView: 0x7fbf06178400; frame = (25 49.9167; 325 34.6667); clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x618000254940>; layer = <CALayer: 0x6180002385e0>; contentOffset: {0, 0}; contentSize: {325, 70}> collection view layout: <UICollectionViewLeftAlignedLayout: 0x7fbf05c5ddb0>.
At first I thought it's a bug UICollectionViewLeftAlignedLayout which I'm using, but the problem didn't go away after I removed UICollectionViewLeftAlignedLayout. Confused, it looks like a mystery system bug I can't solve.
After some trial and error, I found I didn't set a correct preferredMaxLayoutWidth
for the tag label, which should be like this:
tagLabel.preferredMaxLayoutWidth = UIScreen.width - MARGIN_WIDTHS