在Xcode 6 Beta 7及之前的所有版本中,我有一个集合视图,当iPad在横屏和竖屏之间旋转时,它会更新其单元格上的约束条件。现在,它根本不更新,实际上它看起来完全像我在XIB中留下的样子,这意味着它根本没有更新。看起来我正在使用的可重用视图更新正确,但是单元格肯定没有。
还有其他人遇到过这个问题吗?有任何想法如何解决它吗?
我正在使用iOS 7.1模拟器。
还有其他人遇到过这个问题吗?有任何想法如何解决它吗?
我正在使用iOS 7.1模拟器。
@interface MDTCollectionViewCell : UICollectionViewCell
@end
@implementation MDTCollectionViewCell
- (void)setBounds:(CGRect)bounds {
[super setBounds:bounds];
self.contentView.frame = bounds;
}
@end
[cell.contentView setFrame:CGRectMake(0.0, 0.0, cell.frame.size.width, cell.frame.size.height)];
来最接近解决方案,但问题在于子视图(如按钮)的布局不正确,并且不再响应交互。幸运的是,Freitag先生解决了这个问题。现在工作得非常好。 - Justin Whitney作为临时解决方案,覆盖自定义单元格的layoutSubviews
:
override func layoutSubviews() {
contentView.frame = bounds
super.layoutSubviews()
}
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()
})