简体   繁体   中英

UIView Animation breaks TableView

I have a UITableView embedded in a UIView. When a cell is selected, the TableView slides left using UIView Animation so that details underneath can be displayed. When I slide the tableview back to its original frame, the table view can be scrolled over the top of the other elements in the Warpper View. Before the animation, you could only scroll the tableview cells up and down within the boundaries of the tableview. Why is this happening?

- (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){


                 }];
}

I had added a shadow to the view earlier and used:

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

Simply setting back fixes the above:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM