0

我有一个包含 4 个表格视图的水平 UIScrollview。当用户在 tableview 中选择一行时,我添加一个标签并通过更改约束来更改滚动视图的大小。但是,在滚动视图大小更改后,无论用户在哪个表视图上,都会重新加载滚动视图并显示第一个表视图。然后它会崩溃。调试后,我发现原因是旧的 tableview 的数据比第一个少,显示它在 cellForRowAtIndexPath 中因数组绑定错误而崩溃。我的问题是为什么滚动视图会重新加载以及如何让它只是改变大小而不重新加载内容?

// change to the new constrant 
  [self.contentViewConstraint setConstant:height];
  [self.view layoutIfNeeded];

// crash here in cellForRowAtIndex
// reason: index 4 out of bound .... (the current table view has only 3 object while the first tableview has a lot)
  [result fillWithSocialFriend:[self.friends friendAtIndex:indexPath.row]];
4

0 回答 0