- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我希望我的应用针对包括文本大小在内的每个可访问性选项进行优化。
我根据具有组合布局的部分制作了一个 collectionView 布局。所以我需要我的细胞的高度随着它的内容而增长。我想用 .estimated(constant)
会做这项工作,但它似乎不起作用。内部约束对我来说似乎很好。
这是我正在使用的布局:
let size = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.42), heightDimension: .estimated(90))
let item = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(90)))
item.contentInsets = NSDirectionalEdgeInsets(top: 5.0, leading: 12.0, bottom: 5.0, trailing: 12.0)
let group = NSCollectionLayoutGroup.vertical(layoutSize: size, subitem: item, count: 1)
let section = NSCollectionLayoutSection(group: group)
section.contentInsets = NSDirectionalEdgeInsets(top: 0.0, leading: 6.0, bottom: 0.0, trailing: 0.0)
section.orthogonalScrollingBehavior = .groupPaging
NSLayoutConstraint.activate([
self.titleLabel.topAnchor.constraint(equalTo: self.container.topAnchor, constant: 10),
self.titleLabel.leftAnchor.constraint(equalTo: self.container.leftAnchor, constant: 20),
self.titleLabel.rightAnchor.constraint(equalTo: self.container.rightAnchor, constant: -20)
])
NSLayoutConstraint.activate([
self.subtitleLabel.topAnchor.constraint(equalTo: self.titleLabel.bottomAnchor, constant: 10),
self.subtitleLabel.leftAnchor.constraint(equalTo: self.container.leftAnchor, constant: 20),
self.subtitleLabel.rightAnchor.constraint(equalTo: self.container.rightAnchor, constant: -20),
self.subtitleLabel.bottomAnchor.constraint(equalTo: self.container.bottomAnchor, constant: -10)
])
最佳答案
为我解决问题的是为项目和组设置相同的高度尺寸 .
我知道问题的共享代码就是这种情况,@ Que20 的解决方案肯定有帮助。但如果问题仍然存在,您可能需要检查一下。
例子
我正在尝试显示一个包含单个 UIButton 的单元格,该 UIButton 固定在单元格的边缘。该按钮具有 44 点高度限制。
最初的尝试
static func mapSection() -> NSCollectionLayoutSection {
let itemSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1),
heightDimension: .fractionalHeight(1)) // Here: a fractional height to the item
let item = NSCollectionLayoutItem(layoutSize: itemSize)
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1),
heightDimension: .estimated(100)) // There: estimated height to the button cell
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])
let section = NSCollectionLayoutSection(group: group)
return section
}
static func mapSection() -> NSCollectionLayoutSection {
/*
Notice that I estimate my button cell to be 500 points high
It's way too much. But since it's an estimation and we're doing things well,
it doesn't really matter to the end result.
*/
let heightDimension = NSCollectionLayoutDimension.estimated(500)
let itemSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1),
heightDimension: heightDimension)
let item = NSCollectionLayoutItem(layoutSize: itemSize)
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1),
heightDimension: heightDimension)
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])
let section = NSCollectionLayoutSection(group: group)
return section
}
关于ios - 具有估计高度的 Collection View 组合布局不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58339188/
我想计算或至少估计放置在相机/kinect 前面的物体的体积。知道我应该从哪里开始吗?你推荐 OpenCV 吗?您是否推荐任何其他技术,例如声纳/激光? 最佳答案 一直在用 OpenCV 2.3 编写
我想知道 MySQL 对表中总行数的 TABLE_ROWS 估计值是否有限制或保证误差范围? 最佳答案 如果它与 SHOW TABLE STATUS 发出的数字类似,则至少会偏差 +/- 40%,有时
我们都曾 mock 过“还剩 X 分钟”的对话框,它似乎过于简单,但我们如何改进它呢? 实际上,输入是截至当前时间的一组下载速度,我们需要使用它来估计完成时间,也许带有确定性指示,例如使用一些 Y%
我们都曾 mock 过“还剩 X 分钟”的对话框,它似乎过于简单,但我们如何改进它呢? 实际上,输入是截至当前时间的一组下载速度,我们需要使用它来估计完成时间,也许带有确定性指示,例如使用一些 Y%
我的理解是 glmnet 采用矩阵,其中每一列都是一个解释变量。 我有一个包含约 10 个解释变量的数据框(其中一些是因子) 我怎样才能使用诸如 y~(x1*x2*x3)+(x4*x5)+x6 之类的
有没有办法估计运行 R 的时间?命令而不实际运行它或仅部分运行命令? 我知道 system.time()存在但需要运行整个命令然后它给出了花费的时间。 最佳答案 还有http://www.ats.uc
在尝试使用 libGD 在 PHP 中调整图像大小之前,我想检查是否有足够的内存来执行操作,因为“内存不足”会完全杀死 PHP 进程并且无法被捕获。 我的想法是,原始图像和新图像中的每个像素 (RGB
我有一些 VHDL 文件,我可以在 Debian 上用 ghdl 编译它们。一些人已将相同的文件改编为 ASIC 实现。算法有一个“大面积”实现和一个“紧凑”实现。我想编写更多实现,但要评估它们,我需
我在 Amazon EC2 上使用 RStudio 0.97.320 (R 2.15.3)。我的数据框有 20 万行和 12 列。 我正在尝试使用大约 1500 个参数来拟合逻辑回归。 R 使用 7%
我目前正在估算一个新项目。假设只有一名开发人员在处理它,我的高水平估计是 25 周。 实际上会有两个开发人员并行工作。减少估计的什么因素是合理的? (我意识到不会是0.5) 最佳答案 根据原始开发人员
我试图更好地理解创建 Postgres 索引所涉及的权衡。作为其中的一部分,我很想了解通常使用多少空间索引。我已通读 the docs ,但找不到这方面的任何信息。我一直在做自己的小实验来创建表和索引
我对 Azure 平台相当陌生,需要一些有关 Azure 搜索服务成本估算的帮助。每个月我们都会有大约 500GB 的文件被放入 Azure Blob 存储中。我们希望仅根据文件名使用 Azure 搜
我正在尝试最大化横截面面板数据中的数据点数量。我的矩阵结构如下,y 轴为年份,x 轴为国家/地区: A B C D 2000 NA 50 NA
如果我有两个时间序列,例如: t f1 #[1] 0.25 #> f2 #[1] 0.25 f phase_difference #[1] 0.5 这意味着时间序列相移 pi/2,因为它们应该根据
我对 Azure 平台相当陌生,需要一些有关 Azure 搜索服务成本估算的帮助。每个月我们都会有大约 500GB 的文件被放入 Azure Blob 存储中。我们希望仅根据文件名使用 Azure 搜
我使用了以下 R 包:mice、mitools 和 pROC。 基本设计:3 个预测变量度量,在 n~1,000 的数据缺失率在 5% 到 70% 之间。 1 个二进制目标结果变量。 分析目标:确定
如何使用 lsmeans 来估计两个成对对比的差异?例如——想象一个连续的 dv 和两个因子预测变量 library(lsmeans) library(tidyverse) dat % fac
我制作了一个使用 BigDecimal 的科学计算器。它有一个特别消耗资源的功能:阶乘。现在,输入任何数字都会启动计算。根据运行此代码的设备,答案会在不同的时间显示。输入像 50000 这样的巨大值!
我已经发出了 sympy 命令来求解某个方程或另一个方程。现在已经好几天了,我不知道什么时候能完成。 我可以使用 sympy 来记录调用 .solvers.solve 的进度吗?如果不是,我如何估计
最近我得到了一些 error C6020: Constant register limit exceeded at variable; more than 1024 registers needed
我是一名优秀的程序员,十分优秀!