的UITableViewCell子布局的autoLayout残疾故事板搞砸 [英] UITableViewCell subclass layout messed up in autoLayout-disabled Storyboard

查看:150
本文介绍了的UITableViewCell子布局的autoLayout残疾故事板搞砸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了原型细胞的表视图在一个Storyboard与使用自动布局,在X code 5选中。

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

这些细胞的UITableViewCell子类,主要是里面添加IBOutlets没有code。其结果是一个混乱的布局。我试过,没有运气改变口罩自动调整大小。也试过<一个href=\"http://stackoverflow.com/questions/19834718/layoutsubviews-in-uiviewtablecell-does-not-work\">this.

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 它显示ok了。任何想法是怎么回事呢?
为<一个href=\"http://stackoverflow.com/questions/12610783/auto-layout-still-required-after-executing-layoutsubviews-with-uitableviewcel\">auto尽管取消选中它的布局仍启用?

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:


  • 的单元格设置为不自动调整子视图。

  • 尽管以上应该足以从得到自动调整,也都在自动掩模被设定为柔性右侧和只有底部边缘prevent子视图。

  • 只有>标记设置为灵活的左边距。没有灵活的宽度或高度。

推荐答案

细胞是越来越被修改了无证的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.

这样就避免了执行超的 layoutSubviews 修复它。

Thus avoiding executing super's layoutSubviews fixes it.

这篇关于的UITableViewCell子布局的autoLayout残疾故事板搞砸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆