web-dev-qa-db-ja.com

UICollectionViewの構成レイアウト推定されていません

テキストサイズを含むアクセシビリティオプションごとに私のアプリを最適化したいです。

構成レイアウトを持つセクションに基づいて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
 _

ここにアクセス可能な設定に高いテキストサイズを設定すると、次のとおりです。

enter image description here

セルは2つのラベルを含むと想定されています。

    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)
    ])
 _

あなたの助けのために事前にありがとう。

12
Que20

システムのアクセシビリティに関連があるが、afaikは.contentInsets.estimated()を使用することはできません。

それは時々仕事をしますが、信頼できません。私はまたこの権利と戦っているときに、グループに差し込みを適用しようとしていても(それはアイテムのサブクラスであるだろう、それは想像しただろう):(

1
ozzik