作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个 View Controller ,其中包含许多 subview 、建立的所有连接等。我发现我现在需要一个 ScrollView 以允许在较小的屏幕尺寸上显示所有内容。
我的问题是如何将 ScrollView 添加到 View 层次结构的顶部并允许滚动所有 View ?
提前致谢
最佳答案
您需要先创建包含所有 subview 的 UIScrollView
。然后您可以遍历所有顶级 subview 并将它们从它们的父 View 移到 ScrollView 中。
假设在您的 UIViewController
中:
// You will need to handle auto-resize, frame adjustment, and auto-layout stuff
let scrollView = UIScrollView(frame: self.view.frame)
for view in self.view.subviews
{
// Move all subviews from the main view to the scroll view
for subView in self.view.subviews as [UIView]
{
subView.removeFromSuperview()
scrollView.addSubview(subView)
}
}
// Insert the scroll view as the first subview
self.view.insertSubview(scrollView, atIndex: 0)
如前所述,您必须处理这些 View 的布局(自动调整大小的 mask 、约束等)。
关于swift - 将 ScrollView 添加到 Collection View 层次结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29110513/
我正在尝试将多个水平链接的 Button 和 TextView 垂直链接为 View 集,但仍保持平面 View 层次结构。这是我的初始布局和代码:
到目前为止,我已经在Google BigQuery上训练了几种模型,目前我需要查看模型的外观(即架构,损失函数等)。 有没有办法获取这些信息? 最佳答案 仔细阅读文档后,我可以说该功能尚不存在。我什至
本文实例讲述了PHP实现二叉树深度优先遍历(前序、中序、后序)和广度优先遍历(层次)。分享给大家供大家参考,具体如下: 前言: 深度优先遍历:对每一个可能的分支路径深入到不能再深入为止,而且每个
我是一名优秀的程序员,十分优秀!