问题描述:

I currently have only one tableView on the screen to display some data,

and when the data is updated, I use a simple UIAnimation to update the tableView, that is:

Alloc a new tableView with updated data out of the screen first,

then move the old(or current) tableView out of the screen and release it when the animation is done,

at the same time, move the new tableView to the place where the old one was, and with the same direction and velocity of the old one.

So at any moment of this animation, there are TWO tableViews moving towards the same direction on the screen, and the only difference is the old one is moving out, and the new one is moving in.

I believe you can image how it goes.

but question is, when I slow down this animaiton, for instance, make the animationDuration 1.0s,

and I found that during animaion, there's a third tableView, whose data and appearance is totally the same as the one tableView, sticking on the screen with no motion at all, till the new tableView covert it completely,

How I wish I can make it a GIF and display here.

It is just like the ghost of the old tableView! very weird to me, such a greenhand of IOS.

and here is my code to make the animation.

Hoping someone to help me out of the ghost! Thanks a lot!

// .h

@property (nonatomic, assign) UITableView *recordsTable;

// .m

- (void)newTablewithHorizon:(NSInteger) horizon AndVertical:(NSInteger) vertical {

// add Table View

UITableView *newTable = [[UITableView alloc] initWithFrame:

CGRectMake(kTableX - 320*horizon, kTableY - 480*vertical, kTableW, kTableH)

style:UITableViewStylePlain];

newTable.delegate = self;

newTable.dataSource = self;

[self.view addSubview:newTable];

UITableView *formerTable = self.recordsTable;

self.recordsTable = newTable;

UIViewAnimationOptions options = UIViewAnimationOptionCurveEaseInOut;

[UIView animateWithDuration:1.0

delay:0

options:options

animations:^{

CGPoint formerCenter = formerTable.center;

[formerTable setCenter:CGPointMake(formerCenter.x + 320*horizon, formerCenter.y + 480*vertical)];

CGPoint newCenter = self.recordsTable.center;

[self.recordsTable setCenter:CGPointMake(newCenter.x + 320*horizon, newCenter.y + 480*vertical)];

} completion:^(BOOL done) {

if (done)

[formerTable release];

}];

}

相关阅读:
Top