首页 文章

UIView Animation打破了TableView

提问于
浏览
1

我在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

    我之前为视图添加了一个阴影并使用了:

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

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

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

相关问题