1. <i id='WrqKQ'><tr id='WrqKQ'><dt id='WrqKQ'><q id='WrqKQ'><span id='WrqKQ'><b id='WrqKQ'><form id='WrqKQ'><ins id='WrqKQ'></ins><ul id='WrqKQ'></ul><sub id='WrqKQ'></sub></form><legend id='WrqKQ'></legend><bdo id='WrqKQ'><pre id='WrqKQ'><center id='WrqKQ'></center></pre></bdo></b><th id='WrqKQ'></th></span></q></dt></tr></i><div id='WrqKQ'><tfoot id='WrqKQ'></tfoot><dl id='WrqKQ'><fieldset id='WrqKQ'></fieldset></dl></div>

    <legend id='WrqKQ'><style id='WrqKQ'><dir id='WrqKQ'><q id='WrqKQ'></q></dir></style></legend>

    <tfoot id='WrqKQ'></tfoot>

      <bdo id='WrqKQ'></bdo><ul id='WrqKQ'></ul>

      <small id='WrqKQ'></small><noframes id='WrqKQ'>

      UITableViewCell 子类布局在禁用自动布局的故事板中搞砸了

      时间:2023-09-09
      <tfoot id='VGCyf'></tfoot>
    1. <small id='VGCyf'></small><noframes id='VGCyf'>

      <i id='VGCyf'><tr id='VGCyf'><dt id='VGCyf'><q id='VGCyf'><span id='VGCyf'><b id='VGCyf'><form id='VGCyf'><ins id='VGCyf'></ins><ul id='VGCyf'></ul><sub id='VGCyf'></sub></form><legend id='VGCyf'></legend><bdo id='VGCyf'><pre id='VGCyf'><center id='VGCyf'></center></pre></bdo></b><th id='VGCyf'></th></span></q></dt></tr></i><div id='VGCyf'><tfoot id='VGCyf'></tfoot><dl id='VGCyf'><fieldset id='VGCyf'></fieldset></dl></div>

      <legend id='VGCyf'><style id='VGCyf'><dir id='VGCyf'><q id='VGCyf'></q></dir></style></legend>
        <bdo id='VGCyf'></bdo><ul id='VGCyf'></ul>

                  <tbody id='VGCyf'></tbody>

              • 本文介绍了UITableViewCell 子类布局在禁用自动布局的故事板中搞砸了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在 Storyboard 中创建了一个表格视图,其中包含 Xcode 5 中未选中使用自动布局"的原型单元格.

                I have created a table view with prototype cells in a Storyboard with the "Use Autolayout" unchecked in Xcode 5.

                单元格是UITableViewCell的子类,主要是添加IBOutlets,里面没有代码.结果是混乱的布局.我尝试更改 Autoresizing 蒙版,但没有成功.也试过这个.

                The cells are UITableViewCell subclasses, mainly to add IBOutlets and no code inside. The result is a messed layout. I tried changing the Autoresizing masks with no luck. Also tried this.

                但是,如果我实现一个空的 layoutSubviews 则显示正常.知道发生了什么吗?自动布局仍然启用尽管取消选中它?

                If I however implement an empty layoutSubviews it shows ok. Any idea of what's going on? Is auto layout still enabled despite unchecking it?

                更多细节...

                @interface SettingDefaultTableViewCell : UITableViewCell
                
                @property (nonatomic, weak) IBOutlet UILabel *label;
                @property (nonatomic, weak) IBOutlet UIImageView *imageView;
                @property (nonatomic, weak) IBOutlet UIView *backgroundView;
                
                @end
                
                @implementation SettingDefaultTableViewCell
                
                - (void)layoutSubviews
                {
                    // Emtpy implementation to fix weird layout bug
                }
                
                @end
                

                禁用自动布局的故事板:

                Storyboard with Autolayout disabled:

                未使用上述 layoutSubviews 修复时的结果:

                Result when layoutSubviews fix above is not used:

                编辑 2:

                • 单元格设置为不自动调整子视图大小.
                • 虽然以上内容应该足以防止子视图自动调整,但所有自动调整大小的蒙版都设置为仅灵活的右边距和下边距.
                • 只有 > 标记设置为灵活的左边距.没有灵活的宽度或高度.

                推荐答案

                单元格被未记录的 UITableViewCell 的 layoutSubviews 修改:

                The cell is getting modified by the undocumented UITableViewCell's layoutSubviews:

                • 尽管没有设置自动调整大小的子视图,但默认实现会更改 backgroundView 框架.
                • 尽管被配置为自定义样式单元格,它也会将 imageView(>")向左移动.
                • Despite set not no autoresize subviews, the default implementation changes the backgroundView frame.
                • It also moves imageView (the ">") to the left despite being configured as a Custom Style cell.

                从而避免执行 super 的 layoutSubviews 修复它.

                Thus avoiding executing super's layoutSubviews fixes it.

                这篇关于UITableViewCell 子类布局在禁用自动布局的故事板中搞砸了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:指定视图大小何时取决于多个子视图的约束 下一篇:动态更新 UILabel 在 UIView 上的位置取决于它们的文本值

                相关文章

                <small id='1RKZ4'></small><noframes id='1RKZ4'>

                  <legend id='1RKZ4'><style id='1RKZ4'><dir id='1RKZ4'><q id='1RKZ4'></q></dir></style></legend>

                  <tfoot id='1RKZ4'></tfoot>
                    <bdo id='1RKZ4'></bdo><ul id='1RKZ4'></ul>

                1. <i id='1RKZ4'><tr id='1RKZ4'><dt id='1RKZ4'><q id='1RKZ4'><span id='1RKZ4'><b id='1RKZ4'><form id='1RKZ4'><ins id='1RKZ4'></ins><ul id='1RKZ4'></ul><sub id='1RKZ4'></sub></form><legend id='1RKZ4'></legend><bdo id='1RKZ4'><pre id='1RKZ4'><center id='1RKZ4'></center></pre></bdo></b><th id='1RKZ4'></th></span></q></dt></tr></i><div id='1RKZ4'><tfoot id='1RKZ4'></tfoot><dl id='1RKZ4'><fieldset id='1RKZ4'></fieldset></dl></div>