我已经使用稍微不同的技术完成了这一点。也许它对你有用。基本结构是有一个 MainContainerView ,里面是一个 MapView (在你的情况下是一个表格视图)。当我做翻转动画时,我抓取一个单独的视图控制器(列表视图)的视图并将其作为子视图添加到 MainContainerView 并从子视图中删除 MapView。当我想向后翻转时,我会做相反的事情。
-(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
}
}
我希望这会有所帮助,并且可以适用于您的情况!