Objective c UIview位于另一个UIview交换机内,带有新的

Objective c UIview位于另一个UIview交换机内,带有新的,objective-c,ios,uiview,Objective C,Ios,Uiview,我在另一个里面有一个视图。我在我的子视图上有一个按钮,我已经将我的子视图与我创建的IBUIView连接起来,当我点击它时,我希望新视图在它的位置可见。我使用此代码,但我点击时看到白色空白 [UIView beginAnimations:nil context:nil]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:mysubview cache:YES]; [UIView setAnim

我在另一个里面有一个视图。我在我的子视图上有一个按钮,我已经将我的子视图与我创建的IBUIView连接起来,当我点击它时,我希望新视图在它的位置可见。我使用此代码,但我点击时看到白色空白

[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:mysubview cache:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:view1.view cache:YES];
[UIView setAnimationDuration: 1.5];
[UIView commitAnimations];

mysubview.hidden = YES;
newview1.view.hidden = NO;

感谢您的帮助

父视图应该能够通过以下方式切换出其子视图:

transitionFromView:toView:duration:options:completion:
使用给定参数在指定视图之间创建过渡动画

+ (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:     (NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion

我花了好几个小时才拿到的

代码如下:

//获取当前视图

UIView*currentView=mysubview

// hide the previous view
[currentView setHidden:TRUE];
//初始化下一个视图

MyMessages *view1=[[MyMessages alloc] initWithNibName:@"MyMessages" bundle:nil];

[currentView addSubview:view1.view];//add next view to current
[currentView setHidden:FALSE];//show current (actually it should be the next view because we added as a subview)
// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];//show up the new view from right side (this type of effect happens in navigationcontrollers)
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
//
[[currentView layer] addAnimation:animation forKey:@"SwitchToView1"];

什么也没发生![UIView从view:mysubview转换到view:view1.view持续时间:0.5选项:UIViewAnimationOption转换FlipFromLeft完成:^BOOL完成{/*在动画完成时做点什么*/}];您确定要设置动画的视图有效吗?他们是零吗?如何创建和实例化这些视图?UINib?我用xcode中的uiviewcontroller创建了一个项目。然后,我从interface builder在我的项目中添加了一个新的uiview。我将子视图连接到我在代码中创建的ibuiview*子视图。我合成它。然后我在我的项目mysubview的viewdidload=[[UIView alloc]init]中像这样初始化子视图;我想替换的那个我在另一个转换中使用了它,它可以工作,但是我的子视图出了问题,我想,但我不知道它是什么!我所说的关于子视图的话听起来正确吗?