UITableViewCell抛出异常

前端之家收集整理的这篇文章主要介绍了UITableViewCell抛出异常前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在将一个项目更新为iOS 8,并在我的一个UITableViewCell实现中遇到了这个问题.目前在模拟器而不是设备,它被设置为“iPhone 6”.
*** Assertion failure in -[UITableViewCell _setHostsLayoutEngine:],/SourceCache/UIKit_Sim/UIKit-3318/NSLayoutConstraint_UIKitAdditions.m:2754
2014-09-15 10:43:52.890 BasketballStatTracker[10662:304085] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException',reason: 'Must translate autoresizing mask into constraints to have _setHostsLayoutEngine:YES.'

奇怪的是,我在所有其他UITableView中使用了这个Custom UITableViewCell子类,并且没有任何声明就能正常工作.

这是cellForRowAtIndexPath:实现.

MyTableCell *cell =(MyTableCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
    cell =[[MyTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

这是堆栈跟踪

0   CoreFoundation                      0x000000010844e3f5 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x00000001080e7bb7 objc_exception_throw + 45
2   CoreFoundation                      0x000000010844e25a +[NSException raise:format:arguments:] + 106
3   Foundation                          0x0000000107ac228f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4   UIKit                               0x0000000106de2e1c -[UIView(AdditionalLayoutSupport) _setHostsLayoutEngine:] + 188
5   UIKit                               0x00000001069e7d92 -[UITableViewCell _setupTableViewCellCommon] + 333
6   UIKit                               0x00000001069e84d7 -[UITableViewCell initWithCoder:] + 109
7   UIKit                               0x0000000106b8a996 UINibDecoderDecodeObjectForValue + 705

如果任何人有任何想法,将不胜感激.谢谢

解决方法

我找到一个错误的UITableViewCell,它被放置在困扰的.xib的视图层次结构中.删除解决了问题.
原文链接:https://www.f2er.com/iOS/330443.html

猜你在找的iOS相关文章