0
我使用此代码在ios sdk中进行从一个视图到另一个视图的转换,但它仅在第一次工作时,当我返回到之前的视图时,虽然代码被触发,但它不起作用...CATransition的ios代码仅在第一次使用?
UIView * currentView = self.viewController1.view;
// get the the underlying UIWindow, or the view containing the current view view
UIView *theWindow = [currentView superview];
// remove the current view and replace with myView1
[currentView setHidden:TRUE];//hide previous view diladi to tabviewcontroller
self.viewController1=[[MyFriendProfile alloc] initWithNibName:@"MyFriendProfile" bundle:nil];
[theWindow addSubview:self.viewController1.view];
[currentView setHidden:FALSE];
// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[theWindow layer] addAnimation:animation forKey:@"SwitchToView2"];
任何帮助赞赏!
我刚刚试过你的样品,它看起来像为我工作。我所做的唯一的事情就是不使用隐藏的视图,而只是使用addSubview:方法,不要忘记调用removeFromSuperview方法,当你从第二个视图返回第一个视图时 – Denis