0

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.

Paul T.
  • 4,938
  • 7
  • 45
  • 93

2 Answers2

0

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.

SomeGuy
  • 9,670
  • 3
  • 32
  • 35
  • the search is always visible, and position of table doesn't depend on the positin of the search during animation (the position of table in block depends only on the height of the search bar, and this height is constant) – Paul T. Oct 11 '13 at 13:30
  • However it animates, the content inset method should still work in your scenario. – SomeGuy Oct 11 '13 at 13:32
  • I've tried, content insets don't work either (it works like with frames, without animation) – Paul T. Oct 14 '13 at 04:54
0

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?

Community
  • 1
  • 1
Denton
  • 337
  • 3
  • 5