我有一个相当复杂的形式正在编排在UITableView
。这种形式有一些UICollectionView
表视图细胞内,也有一些采摘,显示了它以同样的方式在日历应用:查看更改UITableView更新
现在我做这在我的应用程序时,该UICollectionView
之一,我有得到比它是如何开始高 - 它不断地去(我加了红色边框,以确保它是正在调整的UICollectionView
):
我试着调试UICollectionView
视图属性,但它永远不会改变(它是吸气剂/ setter不会超过我的预期) - 尽管当我在cellForRowAtIndexPath
上打印它时,它确实显示了调整大小。有什么办法可以更好地调试,或者有人处于相同的情况?
谢谢!
代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//self.campos is a dictionary with sections and rows stored
NSMutableArray *infoCampos = [[self.campos objectAtIndex:indexPath.section] objectForKey:@"campos"];
NSDictionary *infoCampo = [infoCampos objectAtIndex:indexPath.row];
if ([[infoCampo objectForKey:@"nome"] isEqualToString:@"dosePorComprimido"]) {
//Remove picker cell if finds it
for (infoCampo in infoCampos) {
if ([infoCampo objectForKey:@"view"] == self.dosagemMedicamento.view) {
[infoCampos removeObject:infoCampo];
[tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
return;
}
}
//Insert new cell
infoCampo = [infoCampos objectAtIndex:indexPath.row];
[infoCampos addObject:@{@"tipo":@5, @"view":self.dosagemMedicamento.view, @"nome":[infoCampo objectForKey:@"nome"]}];
[tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.dosagemMedicamento.view.superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[pickerDosagem]|" options:0 metrics:nil views:@{@"pickerDosagem":self.dosagemMedicamento.view}]];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *infoCampo = [[[self.campos objectAtIndex:indexPath.section] objectForKey:@"campos"] objectAtIndex:indexPath.row];
UIView *view;
if ([infoCampo objectForKey:@"view"]) {
view = (UIView *) [infoCampo objectForKey:@"view"];
return view.frame.size.height;
}
return 44.0f;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath
{
UITableViewCell *cell;
NSMutableDictionary *infoCampo = [[[self.campos objectAtIndex:indexPath.section] objectForKey:@"campos"] objectAtIndex:indexPath.row];
UIView *view;
cell = [tableView dequeueReusableCellWithIdentifier:[[infoCampo objectForKey:@"nome"] stringByAppendingString:@"ViewLinhaCellView"] forIndexPath:indexPath];
view = [cell viewWithTag:1];
[view addSubview:[infoCampo objectForKey:@"view"]];
return cell;
}
编辑:忘了提,我不会更新与reloadData表视图,但与reloadRowsAtIndexPaths和reloadSections只有所需的部分/行。所以这使得它更加怪异,因为我没有重新加载特定的部分。
编辑2:添加的数据源电子委托代码
张贴您的表格视图数据源代码。它似乎是你回到了那个牢房的高度。检查你的heightforcell方法,并确保你的单元格返回适当的值 – CoolMonster
我知道 - 我的heighForRowAtIndexPath只返回子视图的高度,所以问题是这个子视图(UICollectionView)正在调整大小,单元格也是如此。 – dccarmo
你可以发布代码吗?没有代码示例就很难说出什么问题。 – Austin