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

标签 ios uitableview crash uiviewanimation autolayout

我有一个像这样的 UITableView -

enter image description here

我正在使用 UIScrollView 的委托(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>>'

最佳答案

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

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

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

关于ios - 动画 UITableView 自动布局顶部约束导致崩溃,任何线索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21431347/

相关文章:

ios - UITableView 和 UITableViewDataSource

ios - UITableViewCell 中图像的动态帧计算

android-activity - android Activity 崩溃无缘无故?也许是因为setcontentview?

javascript - React-Native TouchableNativeFeedback.Ripple 不起作用

ios - 数据值溢出

ios - 无法在 iOS 上实现 Firebase Phone Auth

ios - Flutter - 如何在 native Swift 代码中调用 channel ?

ios - 自定义动态 TableViewCell 文本定位

java - 当我在每次交替运行的选项卡式 Activity 中按下按钮时,我的应用程序崩溃了

visual-studio-2008 - 尝试加载解决方案文件时 Visual Studio 2008 崩溃