可见的 UITableViewCells 不会在旋转时调整大小 [英] Visible UITableViewCells not resizing on rotate

查看:27
本文介绍了可见的 UITableViewCells 不会在旋转时调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有自定义单元格的 UITableView.当我旋转设备时,可见单元格不会调整大小.滚动到新单元格工作正常,当我向后滚动时,一切都很好,但是有没有办法让初始的可见单元格在旋转时平滑调整大小?

I have a UITableView with custom cells. When I rotate the device, the visible cells do not resize. Scrolling to new cells works fine and when I scroll back, all is well, but is there a way to get the initial, visible cells to smoothly resize on rotate?

[self.tableview reloadData] 来自 UITableViewController;有效,但我认为这不是最佳解决方案,因为它需要网络调用来检索数据.

[self.tableview reloadData] from the UITableViewController; works, but I don't think that is the optimal solution, as it requires a network call for data retrieval.

我已经从 UITableViewController 调用以下代码来布局我使用的一些渐变层,但这对调整 ImageView 的大小没有任何作用.

I am already calling the following code from the UITableViewController in order to layout some gradient layers I use, but this does nothing to resize the ImageView.

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    for (ProjectCell *cell in [[self.tableView.subviews firstObject] subviews]) {
        cell.laidOut = NO;
        [cell layoutSubviews];
    }
}

谢谢

推荐答案

我相信这会满足您的需求:

I believe this will do what you want:

[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:[self.tableView indexPathsForVisibleRows] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];

只要你想重新加载的单元格是可见的单元格.

As long as the cells you want to reload are the visible cells.

这篇关于可见的 UITableViewCells 不会在旋转时调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆