I am trying to animate a tableview on a view that uses autolayout.
I am able to animate the tableview fine but for some reason there is a unwanted sideways animation when doing so.
The first animation closes the top tableview works fine. However the second animation that extends the bottom tableview is the one that has the sideways movement. Here is my code:
[self.dataSelectionTable layoutIfNeeded];
[self.comparatorSelectionTable layoutIfNeeded];
[UIView animateWithDuration:0.5 animations:^{
self.dataSelectionTableHeight.constant = 44;
[self.view layoutIfNeeded]; and then captures all of the frame changes
} completion:^(BOOL finished){
[UIView animateWithDuration:0.5 animations:^{
self.comparatorSelectionTableHeight.constant = 200;
[self.view layoutIfNeeded];
}];
}];
I have tried changing the animation type but that does not seem to work.
Here is a link to a gif that shows the unwanted sideways animation: http://makeagif.com/YubmP2
Edit
Here is the code for populating the tableviews:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
cell.textLabel.numberOfLines = 0;
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:13.0];
}
if (tableView == self.dataSelectionTable) {
cell.textLabel.text = self.dataSelectionTitles[indexPath.row];
}
else {
cell.textLabel.text = [self.comparatorList[indexPath.row] name];
}
return cell;
}