【发布时间】:2015-03-04 12:12:34
【问题描述】:
我正在尝试子类 uitableviewcell。
起初我使用 uitableviewcontroller 没有问题,一切正常
好吧。问题是我无法在 uitableview 的顶部插入静态视图。所以我
开始使用uiview + uitableview。我将委托和数据源设置为我的 uitable
但是当我尝试编译我的解决方案时,我得到了这个错误:
2015-03-04 15:00:53.087 News[7410:750801] *** Assertion failure in -[SubcategoryTableViewCell _setHostsLayoutEngine:], /SourceCache/UIKit/UIKit-3318.16.14/NSLayoutConstraint_UIKitAdditions.m:2760
2015-03-04 15:00:58.132 News[7410:750801] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Must translate autoresizing mask into constraints to have _setHostsLayoutEngine:YES.'
*** First throw call stack:
(0x182b59e48 0x19324c0e4 0x182b59d08 0x1839dd554 0x1873d6088 0x1873df4f0 0x1876f3c60 0x18771475c 0x1877eccc8 0x1877ecc68 0x1877ec984 0x1875c96f8 0x187832244 0x1877eccc8 0x1877ecc68 0x1877ec984 0x1875c96f8 0x1876f3c44 0x18771475c 0x1877eccc8 0x1877ec984 0x187714264 0x1877eccc8 0x1877ecc68 0x1877ec984 0x1877136ec 0x187446cac 0x1000292e8 0x187421854 0x1873e369c 0x1873e58f0 0x1873e582c 0x1873e5178 0x10003ad30 0x100344e30 0x100344df0 0x10034975c 0x182b116a0 0x182b0f748 0x182a3d1f4 0x18bbd35a4 0x18736e784 0x100029bf4 0x1938baa08)
libc++abi.dylib: terminating with uncaught exception of type NSException
关于这部分代码:
- (SubcategoryTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *reuseIdentifier = @"PlaceholderCell2";
SubcategoryTableViewCell * sctvCell = [self.tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
if (sctvCell == nil) {
sctvCell= [[SubcategoryTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
}
在情节提要中,我将我的 uitableviewcell 设置为我的单元格客户类。它的工作原理
完美搭配 uitableview 控制器。
这是我的类和子类代码:
【问题讨论】:
-
这似乎是xCode 6的一个bug。有相关讨论here
-
是的,我想是的。但是有什么解决办法吗!?
-
在 tableview 单元格的 nib 文件中禁用自动布局可能是一种解决方案 (?)
-
我正在使用情节提要解决方案。 uitableviewcell 子类也引用了情节提要中的相同单元格,而没有任何额外的 nib 文件。
标签: ios objective-c uitableview