我有一个UITableView,我通过UIView动画块增加其宽度。自定义的UITableViewCell宽度调整在tableview reloadData
[UIView animateWithDuration:.5
animations:^{
CGRect frame = myTableView.frame;
frame.size.height += 190;
myTableViewView.frame = frame;
[[myTableViewView visibleCells] makeObjectsPerformSelector:@selector(setNeedsDisplay)];
}
completion:nil];
一旦通话结束我的子类UITableViewCells重绘,并调用该委托方法。
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
CGRect frame = cell.frame;
frame.size.width = tableView.frame.size.height;
cell.frame = frame;
}
没有这个,我的UITableViewCells没有绘制到UITableView的全部宽度。我遇到的问题是当我调用[tableView reloadData]。刷新数据调用上述willDisplayCell调用设置正确的框架,但是当我观看的UITableViewCell SETFRAME堆栈跟踪:另一个呼叫正在调用我所有的细胞从一个私人的UITableView电话:
-[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:]
此电话为将我所有可见的UITableViewCells的框架设置为UITableView的原始宽度和较小宽度。有没有人有任何想法如何保持这种情况发生,使我的细胞保持表视图的宽度?
嗨, 这里在UIView动画块,你只是增加高度而不是宽度,如果你想增加这两个适用于这里。 –