Auto Layout in UICollectionViewCell not working

后端 未结 4 497
灰色年华
灰色年华 2020-11-28 19:44

I have a simple UICollectionView with cells that have a single UITextView. The UITextView is constrained to the edges of the cell, so they should stay the same size as the c

4条回答
  •  执笔经年
    2020-11-28 20:19

    Well, I just looked on the iOS developer forums. Apparently, this is a bug with the iOS 8 SDK running on iOS 7 devices. The workaround is to add the following to your subclass of UICollectionViewCell:

    - (void)setBounds:(CGRect)bounds {
        [super setBounds:bounds];
        self.contentView.frame = bounds;
    }
    
    override var bounds: CGRect {
        didSet {
          contentView.frame = bounds
        }
    }
    

提交回复
热议问题