菜鸟教程小白 发表于 2022-12-11 19:21:59

ios - 如何在swift 3中删除tableview中特定单元格的按钮


                                            <p><p>我有一个表格 View ,其中单选按钮编辑和删除按钮被放置在一个特定的表格 View 中,其中键值对 <code>default_shipping</code> 为 true,那么应该隐藏删除按钮并需要编辑按钮移动那个地方,在这里用户可以通过单击编辑按钮来更改默认地址,并且可以将另一个地址设为默认地址,这样选定的地址应该只有编辑按钮,编辑按钮应该放在删除按钮的位置可以谁能帮我实现这个?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><ul>
<li>将编辑按钮的尾随约束赋予 contentView 而不是
删除按钮。</li>
<li>在 UITableViewCell 的类中取出 Edit 按钮的 Trailing 约束</li>
</ul>

<p>在 <code>cellForRowAtIndexPath</code> 中使用以下代码:</p>

<pre><code>if indexPath.row == &#34;your default_shipping cell&#39;s indexPath.row&#34; {

editButtonTrailing.constant = 8

} else {

editButtonTrailing.constant = space between delete and edit button.

}
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何在swift 3中删除tableview中特定单元格的按钮,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/47466651/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/47466651/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何在swift 3中删除tableview中特定单元格的按钮