2

So to make it simple I'm trying to have the same view as in iMessage: a reversed UITableView.

I have a rotated UITableView :

self.tableView.transform = CGAffineTransformMakeRotation(-M_PI);

Each UITableViewCell is also rotated to appear the right way:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
        UITableViewCell *cell = [[UITableViewCell alloc] init];
        cell.transform = CGAffineTransformMakeRotation(M_PI);
        return cell;
}

When the keyboard appears, the frame of my UITableView is changed, so that the bottom of my UITableView follows the top of the keyboard. Same thing when the keyboard hides. To do this I use an animation.

My problem is that when the keyboards hide, the frame of the UITableView increases, and some new cells are displayed. As they are displayed, the delegate calls tableView:cellForRowAtIndexPath: and the animation also applies on the

cell.transform = CGAffineTransformMakeRotation(M_PI);

So I see my new cells rotating!

Is there any way I could avoid the animation on the rotation?

7
  • What is your intention here? Why are you trying to flip a table view by 180°? Do you simply want to reverse the order of cells in the table view?
    – neilco
    Dec 26, 2013 at 12:41
  • I want to reverse it to have, as in the iMessage App, the cells arriving from the bottom (like that : stackoverflow.com/questions/5679835/… ) Dec 26, 2013 at 13:23
  • If all you want it to have the newest cells at the top, reverse the array that provides the data for the cells.
    – neilco
    Dec 26, 2013 at 13:50
  • It's more than that, I want the first cell to be at the bottom of the screen, and to reverse the scroll. Just like iMessage ! Dec 26, 2013 at 13:59
  • Programmatically scroll the table view to the bottom. You're making this harder than it needs to be.
    – neilco
    Dec 26, 2013 at 14:02

2 Answers 2

3

You need to disable animations if you don't want the setting of animatable properties to be animated:

BOOL wasEnabled = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];

cell.transform = CGAffineTransformMakeRotation(M_PI);

[UIView setAnimationsEnabled:wasEnabled];

On iOS 7, you can use [UIView performWithoutAnimation:...].

Also, I would avoid doing

self.tableView.transform = CGAffineTransformMakeRotation(-M_PI);

Last I checked (iOS 5 or 6?), this would cause the cell sizes to be incorrect, as if UITableView used its frame's width to decide how "wide" cells should be. Stick it in a view and set the transform of that view instead (or check that it does the right thing on each major OS version you need to support).

0

Hey mate try to maintain a bool variable when you dont need the animation set the bool variable to false during some editing or any other event. So put the condition of bool variable if it is True then only go for animation.

regards and have a nice year ahead

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.