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