【问题标题】:Animating UITableView’s auto layout top constraint resulting in crash, any clue?动画 UITableView 的自动布局顶部约束导致崩溃,有什么线索吗?
【发布时间】:2014-02-21 06:31:18
【问题描述】:

我有一个这样的UITableView -

我正在用UIScrollView's delegate 中的动画调整这个tblViewTopConstraint -

- (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>>'

【问题讨论】:

  • 我想当用户向上或向下滚动时,您正试图在屏幕上和屏幕外设置导航栏或标题的动画——就像 Facebook 一样。我正在尝试完全相同的方法并且我的动画正在运行,但是如果需要,tableview 在我的动画布局期间会随着高度的增长而闪烁白色。你有没有在你的身上看到过这个?
  • @JasonC.Howlin 是的,我正在像 twitter 一样为视图(看起来像标题)设置动画,但我的不会闪烁。
  • 谢谢!此外,我发现通过这种方法,表格会从用户手指下方轻微移动。您是否注意到这对您的用户来说是个问题?

标签: ios uitableview crash uiviewanimation autolayout


【解决方案1】:

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

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

所以我认为您的问题不在于动画或特定约束。

【讨论】:

    猜你喜欢
    • 2016-02-17
    • 1970-01-01
    • 2017-12-24
    • 1970-01-01
    • 2015-04-02
    • 2014-05-26
    • 2019-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多