添加子视图后,UITableView动画不起作用

时间:2013-05-30 11:13:41

标签: ios objective-c uitableview

字面上!无法理解为什么。这是我的代码人员:

_tableOne_cloned = [_tableOne mutableCopy];

[_tableOne_cloned setFrame:CGRectMake(-320.0f, [_tableOne frame].origin.y, [_tableOne frame].size.width, [_tableOne frame].size.height)];

[[self view] insertSubview:_tableOne belowSubview:_bottomActionBar];

[UIView animateWithDuration:2.5 animations:^{
    [_tableOne setFrame:CGRectMake(-320.0f, [_tableOne frame].origin.y, [_tableOne frame].size.width, [_tableOne frame].size.height)];
}];

事情很简单:我的屏幕上有一个UITableView。当我按下某个UIButton时,UITableView必须消失,另一个将从左侧出现。

但是,这不起作用。如果我删除了我添加新表格的行,那就完美了。

注意:UITableView不符合NSCopying协议,但我创建了一个扩展来支持它。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

当您想要从左侧为其设置动画

 [UIView animateWithDuration:2.5 animations:^{

    [_tableOne setFrame:CGRectMake(-320.0f, [_tableOne frame].origin.y, [_tableOne frame].size.width, [_tableOne frame].size.height)];

}completion:^(BOOL finished) {
     [_tableOne setFrame:CGRectMake(+320.0f, [_tableOne frame].origin.y, [_tableOne frame].size.width, [_tableOne frame].size.height)];

    [UIView animateWithDuration:2.5 animations:^{
        [_tableOne setFrame:CGRectMake(0.0f, [_tableOne frame].origin.y, [_tableOne frame].size.width, [_tableOne frame].size.height)];
    }];

}];