您可以创建一个 ContainerViewController 类,然后像这样推送它:
ContainerViewController *containerViewController = [[ContainerViewController alloc] initWithFrontView: YES];
[self.navigationController pushViewController: containerViewController animated: YES];
[containerViewController release];
类可能看起来像这样:(因为您可以在顶部使用前视图或后视图来推动它)
- (id)initWithFrontView: (BOOL) frontViewVisible {
if (self = [super init]) {
frontViewIsVisible = frontViewVisible;
viewA = [[UIView alloc] init];
viewB = [[UIView alloc] init];
if (frontViewIsVisible) {
[self.view addSubview: viewA];
}
else {
[self.view addSubview: viewB];
}
//add a button that responds to @selector(flipCurrentView:)
}
return self;
}
- (void) flipCurrentView: (id) sender {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
if (frontViewIsVisible == YES) {
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView: self.view cache:YES];
[viewA removeFromSuperview];
[self.view addSubview: viewB];
} else {
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView: self.view cache:YES];
[viewB removeFromSuperview];
[self.view addSubview: viewA];
}
[UIView commitAnimations];
frontViewIsVisible =! frontViewIsVisible;
}
并且不要忘记照顾内存管理。我还建议您查看http://developer.apple.com/library/ios/#samplecode/TheElements/Introduction/Intro.html - 这几乎正是您正在寻找的。