Xcode 9无效的顶部边距位置为我的collectionView在iPhone中大于5s

Xcode 9无效的顶部边距位置为我的collectionView在iPhone中大于5s

问题描述:

我为我的配置文件场景创建了一个简单的用户界面,我使用collectionview,并将顶部约束设置为等于superview(0)。Xcode 9无效的顶部边距位置为我的collectionView在iPhone中大于5s

这在我的iPhone 5S(4英寸iphone)中正常工作,但是在我的iPhone 7,8,8 plus(4.7 & 5.5英寸)中,我的collectionview顶部位置移动到透明导航栏下方,应该如何我做?

我使用此代码透明我的导航栏

override func viewWillAppear(_ animated: Bool) {   
    let bar = (self.navigationController?.navigationBar)! 
    bar.setBackgroundImage(UIImage(), for: .default) 
    bar.shadowImage = UIImage() 
    bar.isTranslucent = true 
    AnalyticsHelper.track(screen) 
} 

这里是我的样品screenshoot

4英寸iPhone看起来不错,它在开始出现Y = 0 iphone 5s looks good and fine with 0 of top constraints

4.7 iPhone和5.5 iphone很奇怪,因为它始于y = 64 invalid top position for 4.7 inch and 5.5 inch

,如果我在func scrollViewDidScroll(_ scrollView:UIScrollView)中检查我的偏移量,我得到0作为iphone 5s中的起始偏移量,但是在较大的iphone中,它将-64作为起始偏移量,为什么会发生这种情况?

我已经解决了这个问题,通过选择内容插入从不在我的CollectionView Size检查器(标尺图标,从右边第二个图标)