我已经设置了一个包含两个视图的多视图应用程序。可以使用每个视图中的按钮切换视图(有两个单独的操作)。我正在使用动画UIViewAnimationTransitionFlipFromRight,当我从第一个视图转到第二个视图时,我将出现在翻转动画后面的视图。我希望它只是白色的。任何帮助表示赞赏。
alt text http://img35.imageshack.us/img35/9982/picture11wu.png
这是切换视图的操作:
- (IBAction)switchViewsOne:(id)sender
{
if (self.uLViewController == nil)
{
ULViewController *uLController =
[[ULViewController alloc]
initWithNibName:@"ULView"
bundle:nil];
self.uLViewController = uLController;
[uLController release];
}
[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
UIViewController *comming = nil;
UIViewController *going = nil;
UIViewAnimationTransition transition;
if (uLViewController.view.superview == nil)
{
comming = uLViewController;
going = mainViewController;
transition = UIViewAnimationTransitionFlipFromLeft;
}
[UIView setAnimationTransition: transition forView:self.view
cache:YES];
[comming viewWillAppear:YES];
[going viewWillDisappear:YES];
[going.view removeFromSuperview];
[self.view insertSubview: comming.view atIndex:10];
[going viewDidDisappear:YES];
[comming viewDidAppear:YES];
[UIView commitAnimations];
}
答案 0 :(得分:0)
你可以尝试使用addSubView,它只是将它添加到堆栈的顶部。
答案 1 :(得分:0)
如果comming.view为nil
,则可能是这种错误[self.view insertSubview: comming.view atIndex:10];
检查,可能你的笔尖没有正确加载
ULViewController *uLController = [[ULViewController alloc] initWithNibName:@"ULView" bundle:nil];
NSLog(@"Loaded controller %@:", uLController);