Go to one UIView view
I have a controller UITableView
rendering static tableview
. I need to update the project by providing a secondary mode in which this one tableview
should flip and show different data. My approach would be to put all the static cells of both modes into one big static one in tableview
order to flip and hide the cell that is not required at that particular moment. The flip should only be performed on tableviewcontrollerview
, therefore, without affecting navigationbar
or main tabbar
. The code I've tried so far to implement this simple magic trick:
// Transition using a page flip.
[UIView transitionFromView:self.tableview
toView:self.tableview
duration:0.7
options:UIViewAnimationOptionTransitionFlipFromLeft
completion:^(BOOL finished) {
if (finished) {
/* HIDE NOT REQUIRED CELL */
}
}];
Unfortunately, the result is a black screen. Any idea how to fix this?
source to share
I think the main problem is that views can have at most one supervisor. This means that the view cannot be in two places at the same time. I would try to grab the view as an image and add it to my supervisor just before the animation and remove the real tableview from my supervisor. And then you can animate between two different views (image view and table view). In the completion block, just delete the image.
How to capture a view: How to capture the current screenshot and reuse it in code? (iPhone SDK)
source to share
I did this using a slightly different technique. It might be helpful for you. the main structure is that there is a MainContainerView and inside is a MapView (in your case a table view). When I do a flip animation, I go through the view of an individual view controller (list view) and add it as a sub to the MainContainerView and remove the MapView from the subview. When I want to lean back, I do the opposite.
-(void)listViewButtonHandler:(id)sender
{
if (_isMap) { //transition to view 2
self.listViewController.view.frame = self.mainContainerView.bounds; //grab the view of a separate VC
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self.mainContainerView
cache:YES];
[self.mapContainerView removeFromSuperview];
[self.mainContainerView addSubview:self.listViewController.view];
[UIView commitAnimations];
self.navigationItem.leftBarButtonItem = [UIBarButtonItem barItemWithImage:[UIImage imageNamed:@"mapButton"] target:self action:@selector(listViewButtonHandler:)]; //change the button to another title
_isMap = NO;
} else {
//transition to view 1
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self.mainContainerView
cache:YES];
[self.listViewController.view removeFromSuperview];
[self.mainContainerView addSubview:self.mapContainerView];
[UIView commitAnimations];
_isMap = YES;
self.navigationItem.leftBarButtonItem = [UIBarButtonItem barItemWithImage:[UIImage imageNamed:@"actualListButton"] target:self action:@selector(listViewButtonHandler:)]; //change the button back
}
}
I hope this is helpful and that it can be applied to your situation!
source to share