【发布时间】:2015-04-10 15:15:04
【问题描述】:
我可以看到集合视图和它的容器之间有 20 像素的间隙,我不知道为什么。我设置了所有约束来拉伸查看整个容器。有什么想法吗?
【问题讨论】:
标签: ios uicollectionview uicontainerview
我可以看到集合视图和它的容器之间有 20 像素的间隙,我不知道为什么。我设置了所有约束来拉伸查看整个容器。有什么想法吗?
【问题讨论】:
标签: ios uicollectionview uicontainerview
您是否可能被限制在边缘? Dubbelclick 您的约束并检查是否检查了“相对于边距”(在第一个/第二个项目下拉列表中)。如果是这样,请取消选中它。
以后您可以使用 |-[]-| 来防止这种情况发生。底部的菜单并在添加约束之前取消选中“约束到边距”。
【讨论】:
对于UICollectionViewController,在过渡后设置视图的框架很重要。在不知何故UITableViewController 自动设置自己。
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let src = segue.sourceViewController as UIViewController
let dst = segue.destinationViewController as UIViewController
addChildViewController(dst)
view.addSubview(dst.view)
dst.didMoveToParentViewController(self)
dst.view.frame = self.view.bounds //<-- this line is important for collection view
}
【讨论】:
self.automaticallyAdjustsScrollViewInsets = NO;
【讨论】: