Custom drawing and UITableViewCell animation when entering edit / reorder mode

I am trying to do something very similar to this post . Starting with Atebits Quick scrolling in Tweetie post I have a subclass of UITableView that does everything it draws in drawRect: its contentView method. It works great and very fast. What I'm trying to do now is to revitalize the transition from editing to non-editing.

An example of what I'm trying to achieve is a situation with some alignment of text in a cell. When you enter edit mode, the ContentView shifts to the right to allow space for editing, but the text also shifts from the screen to the right. If I just call [contentView setNeedsDisplay] in layoutSubviews, I can adjust the right-aligned text, but it just jumps to it in a new position.

How can I get the transition to animation?

+4
source share
1 answer

Your layoutSubviews should look like this:

 -(void)layoutSubviews { [UIView beginAnimations:nil context:nil]; [UIView setAnimationBeginsFromCurrentState:YES]; /* Change offsets here. */ [UIView commitAnimations]; } 

You may also need to add to applicationDidFinishLaunching :

 [UIView setAnimationsEnabled:YES]; 
+1
source

All Articles