美文网首页
Xcode 9/iOS 11自动布局混乱的问题

Xcode 9/iOS 11自动布局混乱的问题

作者: tobin_ | 来源:发表于2017-09-22 15:27 被阅读287次

今天升级了Xcode9,发现之前用的列表自适应高度布局混乱了,每个rowheight都返回44,查了很多技术文档说默认是支持self-sizing,除非设置estimatedRowHeight=0;

self.tableView.estimatedRowHeight = 60;
@property (nonatomic) CGFloat rowHeight;             // default is UITableViewAutomaticDimension
@property (nonatomic) CGFloat sectionHeaderHeight;   // default is UITableViewAutomaticDimension
@property (nonatomic) CGFloat sectionFooterHeight;   // default is UITableViewAutomaticDimension
@property (nonatomic) CGFloat estimatedRowHeight NS_AVAILABLE_IOS(7_0); // default is UITableViewAutomaticDimension, set to 0 to disable
@property (nonatomic) CGFloat estimatedSectionHeaderHeight NS_AVAILABLE_IOS(7_0); // default is UITableViewAutomaticDimension, set to 0 to disable
@property (nonatomic) CGFloat estimatedSectionFooterHeight NS_AVAILABLE_IOS(7_0); // default is UITableViewAutomaticDimension, set to 0 to disable

加了一句

self.tableView.rowHeight = UITableViewAutomaticDimension;

然后就OK了...

相关文章

网友评论

      本文标题:Xcode 9/iOS 11自动布局混乱的问题

      本文链接:https://www.haomeiwen.com/subject/zqsfextx.html