菜鸟教程小白 发表于 2022-12-13 09:27:48

ios - 在 UITableViewCell 中为 detailTextLabel 添加右边距


                                            <p><p>在 UITableViewCell 实例中为 detailTextLabel 添加右边距的最简单方法是什么?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>标准 UITableViewCellLabel 使用的 detailTextLabel 不是标准标签,而是一个特殊的子类,私有(private),称为 UITableViewLabel。自定义它并不容易,因为您可能经历过一些方法被子类覆盖。您可以通过将单元从可重用池中取出来进行一些控制(因为在这种情况下,单元不会重新创建,因此不会再次调用某些被覆盖的方法,在这种情况下将应用基本的 UILabel 设置)但结果不能不能令人满意。 </p>

<p>因此,自定义 View 的最佳方法不是尝试调整现有的现成 View ,而是制作自定义单元格。这可以在 tableView:cellForRow:atIndexPath: 委托(delegate)方法中以编程方式完成,或者通过创建 UITableView 子类或从 nib 文件加载它来完成。即使是这样的简单更改。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 在 UITableViewCell 中为 detailTextLabel 添加右边距,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/7768440/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/7768440/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 在 UITableViewCell 中为 detailTextLabel 添加右边距