iOS 8 GM不会更新集合视图的约束

在Xcode 6 Beta 7及之前的所有版本中,我有一个集合视图,当iPad在横向和纵向之间旋转时,它将更新其单元格上的约束。 现在它根本没有更新,实际上它看起来和我在XIB中保持一致,这意味着它根本不会更新。 看来我正在使用的可重复使用的视图正确更新,但单元格当然不是。

有没有人遇到这个问题呢? 任何人有任何想法如何通过它?

我正在使用iOS 7.1模拟器。

您需要创buildUICollectionViewCell的子类,并将该子类作为所有单元的超类。

例:

@interface MDTCollectionViewCell : UICollectionViewCell @end @implementation MDTCollectionViewCell - (void)setBounds:(CGRect)bounds { [super setBounds:bounds]; self.contentView.frame = bounds; } @end 

将自定义单元的layoutSubviews作为临时修订覆盖:

 override func layoutSubviews() { contentView.frame = bounds super.layoutSubviews() } 

我提出的解决方法是使用8.0模拟器在SIM卡中进行testing,并使用Xcode Beta 7构build可部署的应用程序。使用Beta 7构build应用程序时,应用程序在使用iOS 7的设备上运行时不会出现此问题。但是,不会帮助任何人部署到应用程序商店,所以我很抱歉,如果这种解决方法不适合您的情况。

在我添加的UICollectionViewCell类中

 override func layoutSubviews() { contentView.frame = bounds super.layoutSubviews() } 

我用这个代码来刷新

 dispatch_async(dispatch_get_main_queue(), { () -> Void in // in this case vController is UICollectionView self.vController.reloadData() self.vController.layoutSubviews() })