我正在构建一个 iPad 应用程序,并想通过按一个按钮将我的一个子视图切换为另一个。我一直在阅读文档和本指南:
但我不断收到错误,动画并没有真正发生,视图只是立即切换。
我将在下面粘贴一些代码作为上下文。我有一个主视图,其中有一个子uiview。在子uiview中,还有另外一个view。我想用另一个视图交换另一个视图。
self.settingsViewController = [[GHPSettingsViewController alloc] initWithNibName: @"GHPSettingsViewController" bundle: nil andParent: self];
UIView *outerView = [self.containingView viewWithTag:0];
[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration: 100.25f];
[UIView setAnimationDuration: UIViewAnimationCurveEaseInOut];
if (self.settingsViewController.view.superview == nil) {
// Flip Out Old View
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.containingView cache:YES];
[self.settingsViewController viewWillAppear: YES];
[outerView removeFromSuperview];
[self.containingView insertSubview: self.settingsViewController.view atIndex: 0];
[self.settingsViewController viewDidAppear: YES];
}
[UIView commitAnimations];