简体   繁体   中英

ios7 animateWithDuration with tableview issue

I have method to animate simultaneously search bar and table view ( viewFilterResults is just one of the views):

            CGFloat heightSearchBar = CGRectGetHeight(_searchBar.frame);
            [UIView animateWithDuration:animationDuration delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
                CGRect frameSearch = _searchBar.frame;
                frameSearch.origin.y = CGRectGetMaxY(self.viewFilterResults.frame);
                _searchBar.frame = frameSearch;

                CGRect frameTable = _plantsListTableView.frame;
                frameTable.origin.y = CGRectGetMaxY(self.viewFilterResults.frame) + heightSearchBar;
                frameTable.size.height = CGRectGetHeight(self.view.frame) - CGRectGetMinY(frameTable);
                _plantsListTableView.frame = frameTable;
            } completion:^(BOOL finished) {
                if (completionBlock) {
                    completionBlock();
                }
            }];

on iOS 6 and 5 everything is OK, but on iOS 7 search bar animation is OK, but table view moves to proper place without animation. May be it's impossible to animate table view on iOS 7 ?

update:

I've tried to animate content insets of table view, but the result is the same. So that didn't help.

I'm assuming this is for a moving UISearchBar and adjusting the table's frame depending whether the search is visible or not?

If so, instead of the frame, keep the table view at it's maximum frame (even if it's behind the scroll bar) and just adjust it's contentInset to push the content down.

Autolayout/constraints might be causing the problem.

I ran into a similar problem in iOS7 where I was animating 2 separate views simultaneously. The 1st view's constraints were strangely causing animation for 2nd view to be incomplete. The strangest part is that there was no problem with this in iOS6 even with the constraints.

If you find constraints are indeed the problem, the "Autolayout vs. View Transforms" answer here has some helpful info: How do I adjust the anchor point of a CALayer, when Auto Layout is being used?

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