如何UITableViewCell在表格视图中使用s 内的自动布局,让每个单元格的内容和子视图确定行高(本身/自动),同时保持平滑的滚动性能?
使用XCode 4.5和iOS 6,我正在开发一个带有自定义单元格的简单表视图的应用程序.我已经在iOS 5及以下版本中完成了这一百次,但由于某种原因,新的autoLayout系统给了我很多麻烦.
我在IB中设置了我的表格视图和原型单元格,添加了子视图并将它们连接起来作为IBOutlets然后设置我的委托和dataSource.但是现在每当从第一个单元格中取出时cellForRowAtIndexPath,我都会收到以下错误:
***断言失败 - [ShopCell layoutSublayersOfLayer:],/ SourceCache/UIKit_Sim/UIKit-2372/UIView.m:5776
***由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'执行-layoutSubviews后仍需要自动布局.ShopCell的-layoutSubviews实现需要调用super.
我没有在我的子类化单元格(ShopCell)中实现-layoutSubviews方法,即使我尝试这样做并添加超级调用,因为它表明我仍然得到相同的错误.如果我从IB中的单元格中删除子视图,并将其更改为标准的UITableViewCell,一切都按预期工作,但当然我的单元格中没有数据.
我几乎可以肯定,我有一些简单的东西,但我找不到任何文件或指南来暗示我做错了什么.任何帮助,将不胜感激.
编辑:只是尝试将其更改为IB中的UITableViewCell并保留所有子视图,仍然是相同的错误.
我正在以编程方式使用自动布局约束来布局我的自定义UITableView单元格,并且我正确地定义了单元格大小 tableView:heightForRowAtIndexPath:
它在iOS6上运行得很好,在iOS7中看起来也很好
但是当我在iOS7上运行应用程序时,这是我在控制台中看到的那种消息:
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2013-10-02 09:56:44.847 Vente-Exclusive[76306:a0b] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or …Run Code Online (Sandbox Code Playgroud) autolayout ×3
ios ×3
uitableview ×2
ios7 ×1
nsautolayout ×1
objective-c ×1
row-height ×1
xcode4.5 ×1