UIView Animation打破了TableView

时间:2014-02-28 15:06:32

标签: ios animation uiview scroll bounce

我在UIView中嵌入了一个UITableView。选择单元格后,TableView将使用UIView Animation向左滑动,以便显示下面的详细信息。当我将tableview滑回原始框架时,表格视图可以滚动到Warpper视图中其他元素的顶部。在动画之前,您只能在tableview的边界内上下滚动tableview单元格。为什么会这样?

- (void)slideTableView:(BOOL)reset
{

    //Current pos
    CGRect newTableViewFrame = self.tableView.frame;

    //Determine direction based on current pos
    int newX;

    if (reset || newTableViewFrame.origin.x < 0) {
        newX = newTableViewFrame.origin.x=0;
    }
    else {
        newX = newTableViewFrame.origin.x - 280;
    }

    newTableViewFrame.origin.x =newX;

    CGFloat animationDuration = 0.2;
    CGFloat animationDelay = 0.0;

    [UIView animateWithDuration:animationDuration delay:animationDelay options:UIViewAnimationOptionCurveEaseInOut
                 animations:^{

                     self.tableView.frame=newTableViewFrame;

                 }
                 completion:^(BOOL finished){


                 }];
}

1 个答案:

答案 0 :(得分:0)

我之前在视图中添加了阴影并使用了:

self.clipsToBounds = NO; 
self.layer.masksToBounds = NO; 

简单地回设修复上述内容:

self.clipsToBounds = YES;  
self.layer.masksToBounds = YES;