菜鸟教程小白 发表于 2022-12-11 19:36:52

ios - 使用两个项目的水平滚动时右对齐 UICollectionView(用于 RTL)


                                            <p><p>我目前也在开发一个支持从右到左语言的项目。到目前为止,在 Apple 的 RTL 支持下,我管理了 %80 的项目来支持 RTL。但是我被 UICollectionView 卡住了。</p>

<p><strong>对于 LTR 语言,一切正常,如下所示:</strong></p>

<p> <img src="/image/4H8fb.gif" alt="enter image description here"/>
<img src="/image/3e4zJ.png" alt="enter image description here"/>
<img src="/image/BLx0l.png" alt="enter image description here"/> </p>

<p><strong>然而</strong>,当 RTL 被激活时,请看下面, Collection View 正在成功加载,但是当它试图展开或换句话说重新加载时,它再次像 LTR 一样,我猜。我添加了慢动作 gif,以便为您提供有关行为的一些信息。</p>

<p> <img src="/image/mREdk.gif" alt="enter image description here"/>
<img src="/image/deoGq.png" alt="enter image description here"/>
<img src="/image/IZkto.png" alt="enter image description here"/> </p>

<p><strong>知道为什么会这样吗?
请不要,我提到了<a href="https://stackoverflow.com/questions/19712201/ios-uicollectionview-default-flow-fill-rows-from-right-to-left/20803186#20803186" rel="noreferrer noopener nofollow">this answer here</a> ,但是它使用垂直滚动,而不是水平滚动。</strong></p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>-你确定你在 AutoLayout 中的约束是正确的吗?
- 而不是设置 RTL,
首先在创建 UICollectionView 时对其进行水平翻转。
    <code>;</code></p>

<p>然后在 CellForItemAtIndexPath 方法中返回一个单元格之前,给该单元格水平翻转。</p>

<pre><code>;
</code></pre>

<p>希望它会有所帮助。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 使用两个项目的水平滚动时右对齐 UICollectionView(用于 RTL),我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/43755720/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/43755720/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 使用两个项目的水平滚动时右对齐 UICollectionView(用于 RTL)