UITableViewCell + Autolayout + RTL

我将我的应用程序本地化为希伯来语,这是一种RTL语言。
每个单元格具有水平约束设置为前导/尾随在RTL语言自动反转。
最后的结果与预期完全一致,但是当滚动浏览表格视图时,UITableViewCell子视图从LTR animation到RTL,这非常奇怪。

有没有办法来防止animation的意见?

例:

Imgur

在所有的WWDCvideo中也没有这个词

你可以在 – (无效)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)单元forRowAtIndexPath:(NSIndexPath *)indexPath的约束animation,有一个例子,我用我的代码,但不animation约束,而是animation单元格的contentview的图层的变换

 - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { UIView *contentView = cell.contentView; contentView.layer.opacity = 0.0; contentView.layer.transform = CATransform3DMakeScale(0.2, 2, 0.3); [UIView animateWithDuration:0.5 animations:^{ contentView.layer.opacity = 1; contentView.layer.transform = CATransform3DIdentity; }]; 

}

OK,所以基本上UIView是以原始布局启动的,因为它出现在*.XIB文件中,然后改变布局作为设备的本地化。

我的UITableViewCell第一次被显示,没有animation,它显示正常,我认为我的UITableView重用它的单元格,因为这是我如何定义它,但实际上,由于另一个问题,我已经错误地造成,我的tableView内容大小在滚动过程中发生了变化,旧的单元格没有被重用,什么导致像20个“活”单元格一样被表格视图同时查看,所以每一个新行都刚启动了一个新的UITableViewCell ,同时还有一个方法正在执行

 [UIView animateWithDuration:.2 animations:^{ ... [self.view layoutIfNeeded]; ... }]; 

单元格的布局也是从LTR到RTL布局的animation。

无论如何,修复这个行为的实现解决了单元格的重用以及由全局视图的布局animation引起的奇怪的animation。

希望它能帮助其他遇到类似问题的人。