菜鸟教程小白 发表于 2022-12-11 18:15:24

ios - 如何在 UIView swift 中重新加载特定的 subview ?


                                            <p><p>在主 <code>UIView</code> 中,我有 3 个 subview 。我只想刷新一个 subview 。</p>

<p>我的问题,当我想删除 subview 中数组的索引并刷新它时,我将数组放在一个 subview 中。</p>

<p>我确实尝试过这种方法。</p>

<ol>
<li><p><code>- (void)layoutSubviews</code></p></li>
<li><p><code>- (void)layoutIfNeeded</code></p></li>
</ol>

<p>还有:</p>

<p><code>- (void)setNeedsLayout</code> </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p><strong>您可以在 UIVIew 和 UIViewController 类之间创建委托(delegate)关系。</strong>
然后在委托(delegate)方法中添加适当的代码以重新加载 UIVIew。</p>

<p>否则,您可以在 View 上调用 <code>setNeedsDisplay</code> 从而强制它重绘。这不是正确的做法。</p>

<p> <a href="https://www.codementor.io/leoiphonedev/delegates-in-swift-hvim2n7s1" rel="noreferrer noopener nofollow">Totorial to make Delegates</a> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何在 UIView swift 中重新加载特定的 subview ?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/45053576/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/45053576/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何在 UIView swift 中重新加载特定的 subview ?