动画UITableView的自动布局顶部约束导致崩溃,任何线索?

时间:2014-01-29 12:36:52

标签: ios uitableview crash uiviewanimation nsautolayout

我有UITableView喜欢这个 -

enter image description here

我正在使用tblViewTopConstraint -

中的动画调整此UIScrollView's delegate
- (void) scrollViewDidScroll:(UIScrollView *)scrollView

动画代码 -

[self.tblViewTopConstraint setConstant:45.0f];
[UIView animateWithDuration:0.4f delay:0.f options:UIViewAnimationOptionCurveEaseOut animations:^{
        [self.tblView.superview layoutIfNeeded];
    } completion:^(BOOL finished) {
    }];

动画工作正常,但如果我向上/向下滚动UITableView 5-6次,它会突然抛出这个崩溃 -

*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to install constraint on view.  Does the constraint reference something from outside the subtree of the view?  That's illegal. constraint:<NSAutoresizingMaskLayoutConstraint:0xa75abb0 h=--& v=--& XYZCustomCell:0xb4c6f00.width == UITableViewWrapperView:0xb4bb710.width> view:<UITableViewWrapperView: 0xb4bb710; frame = (0 0; 320 459); autoresize = W+H; layer = <CALayer: 0xb4ca150>>'

1 个答案:

答案 0 :(得分:0)

错误说,导致崩溃的约束是宽度约束:

constraint:<NSAutoresizingMaskLayoutConstraint:0xa75abb0 h=--& v=--& XYZCustomCell:0xb4c6f00.width == UITableViewWrapperView:0xb4bb710.width>

所以我不认为你的问题出在动画或特定约束上。