菜鸟教程小白 发表于 2022-12-11 20:44:48

ios - 无法使用 AutoLayout 设置 UICollectionViewCell 内容的宽度


                                            <p><p> <a href="/image/bV8Yv.png" rel="noreferrer noopener nofollow"><img src="/image/bV8Yv.png" alt="enter image description here"/></a> </p>

<p>我正在使用 Collection View 创建一个 GridView ,但一些大型 iPhone 在右侧有间距。</p>

<p>我在 collectionViewLayout 方法中使用了下面的代码:</p>

<pre><code>return CGSizeMake(cellSize / 4, cellSize /4)
</code></pre>

<p>请查看图片了解更多详情。 </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>单元大小不是问题。问题在于<strong>间距</strong>。它不能同时具有<strong>固定项目大小</strong>和<strong>固定项目间距</strong>。所以你必须让其中之一动态化。</p>

<p>尝试在 flowLayout 中计算间距或项目大小;)</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 无法使用 AutoLayout 设置 UICollectionViewCell 内容的宽度,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/53022426/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/53022426/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 无法使用 AutoLayout 设置 UICollectionViewCell 内容的宽度