I am using a single UITableView within my app. I change the delegate and datasource of the UITableView depending upon row selections etc.
To animate the transitions as the user moves around I grab an image of the current UITableView , place the image in a UIImageView placed over the top of the UITableView, reloadData on the UITableView, then remove the UIImageView within an animated transition.
Code as follows:
-(void)showImageEditPageWithImageId:(NSString*)imageId
{
UITableView* tableview = (UITableView*)[self.view viewWithTag:VIEWTAG_P1_MAINTABLEVIEW];
UIImage* image = [HPSImageHelper imageWithView:tableview];
UIImageView* imageView = [[UIImageView alloc] initWithFrame:tableview.frame];
imageView.tag = 336611;
imageView.layer.borderWidth=1;
imageView.layer.borderColor = [UIColor blueColor].CGColor;
[imageView setImage:image];
_tableViewController = [[HPSImageEditTableViewController alloc] initWithImageId:imageId];
((HPSImageEditTableViewController*)_tableViewController).callingController = self;
tableview.dataSource = _tableViewController;
tableview.delegate = _tableViewController;
[tableview reloadData];
[tableview.superview addSubview:imageView];
[NSTimer scheduledTimerWithTimeInterval:0.1
target:self
selector:@selector(removeCoveringImage)
userInfo:nil
repeats:NO];
}
-(void)removeCoveringImage
{
UIView* imageView = [self.view viewWithTag:336611];
[UIView transitionWithView:imageView
duration:0.9
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
//Nothing here
}
completion:^(BOOL finished){
[imageView removeFromSuperview];
}
];
}
The trouble is, the UITableView only visually refreshes itself once the transition is complete, so the new view suddenly jumps into view.
It seems to me that the UITableView is not refreshing itself because it ‘knows’ it isn’t actually visible.
Is that what’s happening, and if so how do I get the UITableView to redraw even though it is covered by the UIImageView?
Thanks.
Try calling setNeedsDisplay on your table view after load data. If that doest help try add UIViewAnimationOptionLayoutSubviews option to your animation. If nether of those help, try to lower alpha of imageView only slightly enough(0.99 or 0.98 or 0.90) to force tableView to redraw before animation. Hope this helped