-2

如果我在删除一行时更改 UITableView 的框架,例如这里:

tableView:commitEditingStyle:forRowAtIndexPath:
{
    [tableView setFrame:CGRectMake(tableView.frame.origin.x, tableView.frame.origin.y, tableView.frame.size.width, tableView.frame.size.height + 40]
}

我没有看到表格布局有任何变化。我是否需要刷新视图才能使用新框架显示表格?

谢谢

4

3 回答 3

0

也许您还需要更新tableView.contentSize = tableView.frame

否则使用

[tableView setNeedsLayout];
[tableView setNeedsDisplay];

重绘tableView的方法

于 2013-09-02T08:52:43.420 回答
0

您可以使用以下代码删除该行。

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationBottom];
numberofRowsinTable--;

在那之后,

[tableview reloadData];

您还需要减少并返回表的行数

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return numberofRowsinTable;
}
于 2013-09-02T08:12:00.153 回答
0

尝试这个。

[tableView beginUpdates];
[tableView setFrame:CGRectMake(tableView.frame.origin.x, tableView.frame.origin.y, tableView.frame.size.width, tableView.frame.size.height + 40];
[tableView endUpdates];
于 2013-09-02T08:03:47.323 回答