UITableView框架高度动画故障 [英] UITableView frame height animation glitch

查看:101
本文介绍了UITableView框架高度动画故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我尝试为 tableView 的框架高度设置动画(例如: height - = 200 ),在帧的平滑动画完成之前,最后200px中出现的单元格突然消失。

If I attempt to animate the frame height of a tableView (ex: height -= 200), the cells that appear in the last 200px disappear suddenly before the smooth animation of the frame completes.

为了确保它不是我正在做的其他事情,我创建了一个新视图基于应用程序。在主 viewController 中,我创建了自己的 tableview ,其中包含足够的 伪行 来填充整个屏幕。在选择一行时,我会做一个简单的高度动画。

To make sure that it's nothing else I'm doing, I created a new View-Based application. In the main viewController I create my own tableview with enough pseudo rows to fill the entire screen. And on selection of a row I do a simple height animation.

最相关的代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.myTable = [[[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)] autorelease];
    myTable.delegate = self;
    myTable.dataSource = self;
    [self.view addSubview:myTable];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    CGRect frame = self.myTable.frame;
    frame.size.height = 200;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDelay:.5f];
    [UIView setAnimationDuration:0.5f];
    self.myTable.frame = frame;
    [UIView commitAnimations];
}

有谁知道为什么会这样,或者修复/解决方法可能是什么?

Does anyone know why this is happening, or what a fix/workaround may be?

任何建议都非常感谢。
TIA!

Any suggests are really appreciated. TIA!

推荐答案

我不确定完全同样的问题,但是使用 [UIView setAnimationBeginsFromCurrentState:YES]; 解决了(部分)毛刺(我的表格视图在动画帧高度变化时疯狂滑动)。

I'm not sure I had exactly the same problem, but using [UIView setAnimationBeginsFromCurrentState:YES]; solved (parts of) the glitches (my table view slid around crazily when animating a frame height change).

这篇关于UITableView框架高度动画故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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