格式化主要单元格以进行水平滚动后,我收到一条警告,通知整个控制台都是垃圾邮件,只会使我烦恼。
我已经尝试过更改约束和像元大小,但是警告总是以一种或另一种方式出现。
在我的feedCell类中:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: frame.width, height: UIScreen.main.bounds.height / 3.5)
} //Sets each cell's frame
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
} //Removes spacing between the cells
在mainView类中,我使用的水平滚动单元定义为:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: view.frame.width, height: view.frame.height-60)
}
我还使用以下方法初始化菜单栏:
private func setupMenuBar() {
navigationController?.hidesBarsOnSwipe = true
view.addSubview(menuBar)
view.addConstraintsWithFormat(format: "H:|[v0]|", views: menuBar)
view.addConstraintsWithFormat(format: "V:|[v0(60)]", views: menuBar)
}
我还将导航栏设置为
navigationController?.hidesBarsOnSwipe = true
我的状态栏高度等于20,但我认为这不是主要问题。
错误消息:
2019-06-14 19:38:55.755740+0300[71578:4274545] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2019-06-14 19:38:55.756169+0300[71578:4274545] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x7faba0f027d0>, and it is attached to <UICollectionView: 0x7faba1047000; frame = (0 0; 414 808); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600002e7c360>; layer = <CALayer: 0x600002074d40>; contentOffset: {0, -50}; contentSize: {0, 0}; adjustedContentInset: {50, 0, 34, 0}> collection view layout: <UICollectionViewFlowLayout: 0x7faba0f027d0>.
2019-06-14 19:38:55.756248+0300[71578:4274545] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
答案 0 :(得分:0)
我已解决此问题。如果任何人也遇到此问题,请确保您未使用UIScreen.main.bounds.height作为单元格大小,并且将hidesBarsOnSwipe设置为true。这似乎为我解决了。